Skip to content
Example of turning apps to golem
R
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
060-retirement-simulation-golem
060-retirement-simulation
README.Rmd
README.md
golemize.Rproj

README.md

golemize

Example of turning a classical standard app to {golem}.

From github.com/rstudio/shiny-examples/060-retirement-simulation

Structure

Shiny Example :

fs::dir_tree("060-retirement-simulation")
#> 060-retirement-simulation
#> ├── DESCRIPTION
#> ├── server.r
#> ├── ui.r
#> └── www
#>     └── simplex.min.css

{golem} example:

fs::dir_tree("060-retirement-simulation-golem")
#> 060-retirement-simulation-golem
#> ├── 060-retirement-simulation-golem.Rproj
#> ├── DESCRIPTION
#> ├── NAMESPACE
#> ├── R
#> │   ├── app_server.R
#> │   ├── app_ui.R
#> │   ├── run_app.R
#> │   ├── utils_server.R
#> │   └── utils_ui.R
#> ├── data
#> │   └── paramNames.rda
#> ├── data-raw
#> │   └── DATASET.R
#> ├── dev
#> │   ├── 01_start.R
#> │   ├── 02_dev.R
#> │   ├── 03_deploy.R
#> │   └── run_dev.R
#> ├── inst
#> │   └── app
#> │       └── www
#> │           ├── favicon.ico
#> │           └── simplex.min.css
#> └── man
#>     └── run_app.Rd

Where to put things

CSS & metadata

In {golem}, the external dependencies goes into inst/app/www. Then, they need to be linked to in app_ui.R, in golem_add_external_resources(). If you’re creating the file with add_css_file() for example, the file will be opened and you’ll have in your console the piece of code to copy into app_ui.R.

Server

Take your server.R file, and split it into pieces. The body of the main server function foes into the function skeleton in R/app_server.R. The other server functions can be placed in other files in the R/folder. The data defined can either be defined as golem options or it can be created as a package data.

UI

Same dance for the UI part.

Dep

Launch the {golem}

  • You can run the whole dev/run_dev.R script.

  • You can run pkgload::load_all();mygolem::run_app()

You can’t perform that action at this time.