https://github.com/shinyworks/shinyenv
User-Specific Shiny Environments
https://github.com/shinyworks/shinyenv
Last synced: 13 days ago
JSON representation
User-Specific Shiny Environments
- Host: GitHub
- URL: https://github.com/shinyworks/shinyenv
- Owner: shinyworks
- License: other
- Created: 2024-02-01T21:48:49.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-05T15:24:52.000Z (about 1 year ago)
- Last Synced: 2024-11-02T16:08:09.871Z (5 months ago)
- Language: R
- Homepage: https://shinyenv.shinyworks.org/
- Size: 3.78 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.Rmd
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Support: .github/SUPPORT.md
Awesome Lists containing this project
- jimsghstars - shinyworks/shinyenv - User-Specific Shiny Environments (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# shinyenv
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[](https://CRAN.R-project.org/package=shinyenv)
[](https://app.codecov.io/gh/shinyworks/shinyenv?branch=main)
[](https://github.com/shinyworks/shinyenv/actions/workflows/R-CMD-check.yaml)An experimental package to deal with environment-like variables in Shiny.
## Installation
You can install the development version of shinyenv from [GitHub](https://github.com/) with:
```{r eval = FALSE}
# install.packages("pak")
pak::pak("shinyworks/shinyenv")
```Alternatively, you can use the functions without taking a dependency on {shinyenv}:
```{r eval = FALSE}
# install.packages("usethis")
usethis::use_standalone("shinyworks/shinyenv", "envvars")
```## Usage
### You probably shouldn't use this package.
> You might see advice to use `session$userData` or other techniques to break out of the module straitjacket. Be wary of such advice: it’s showing you how to work around the rules imposed by namespacing, making it easy to re-introduce much complexity to your app and significantly reducing the benefits of using a module in the first place.
> -- Hadley Wickham, [Mastering Shiny](https://mastering-shiny.org/scaling-modules.html#inputs-and-outputs)You should almost always use Shiny's built-in mechanisms for setting and accessing variables.
I highly recommend reading [Mastering Shiny](https://mastering-shiny.org/) to be certain that you actually need this type of variable before using the options presented here.Shiny variables can be roughly divided into three categories:
- **App-wide variables that apply to all users:** Use normal R variables, options (`getOption()`), and/or environment variables (`Sys.getenv()`).
- **Variables that apply to a single user:** Almost always use Shiny's `reactiveValues()`, `reactiveVal()`, `reactive()`, the `input` system, and/or return values from modules.
- **Variables that apply to a single user, are shared across multiple modules, and can be updated in multiple places:** Use this package. These should be places where, in a non-Shiny context, you would use `Sys.setenv()` to set a variable (for yourself) and `Sys.getenv()` to get it.### But if you're sure you want to...
Instead of `Sys.setenv()`, use `shinyenv::shiny_setenv()`,
```{r eval = FALSE}
# NO: Sys.setenv(foo = "bar", baz = "foo")
shinyenv::shiny_setenv(foo = "bar", baz = "foo")
```Instead of `Sys.getenv()`, use `shinyenv::shiny_getenv()`,
```{r eval = FALSE}
# NO: Sys.getenv("foo")
shinyenv::shiny_getenv("foo")
```## Code of Conduct
Please note that the shinyenv project is released with a [Contributor Code of Conduct](https://shinyworks.github.io/shinyenv/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.