⚠️There's a newer version (0.4.1) of this package. Take me there.

{golem}

{golem} is a package that provides tools for a better workflow for working on shinyapps.

Installation

You can install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("Thinkr-open/golem")

Launch the project

Create a new package with the project template:

Step by step guide

See full documentation in the {pkgdown} website: https://thinkr-open.github.io/golem/index.html

After project creation, you’ll land on dev_history.R. This file is used to keep a track of all the steps you’ve followed to build your app.

You can follow it step by step of skip some if you’d like.

Fill the description

golem::fill_desc() allows to fill the DESCRIPTION quickly.

golem::fill_desc(
  pkg_name = , # The Name of the package containing the App 
  pkg_title = , # The Title of the package containing the App 
  pkg_description = , # The Description of the package containing the App 
  author_first_name = , # Your First Name
  author_last_name = , # Your Last Name
  author_email = , # Your Email
  repo_url = NULL) # The (optional) URL of the GitHub Repo

Set common Files

Call the {usethis} package to set a list of elements:

usethis::use_mit_license(name = "Your Name")
usethis::use_readme_rmd()
usethis::use_code_of_conduct()
usethis::use_lifecycle_badge("Experimental")
usethis::use_news_md()

If you have data in your app:

usethis::use_data_raw()

Use Recommended Package

This adds a series of packages as dependecies to your app. See ?golem::use_recommended_dep for the list.

golem::use_recommended_dep(recommended = c("shiny","DT","attempt","glue","htmltools","golem"))

Add various tools

These three functions adds one file each which contain a series of functions that can be useful for building your app. To be used in the UI, in the server, or as prod-dependent tools.

golem::use_utils_ui()
golem::use_utils_server()

Somes JS functions can also be used inside your shiny app with:

golem::js()

See ?golem::js for the list.

Add a browser button

golem::add_browser_button()

See A little trick for debugging Shiny for more info about this method.

Create modules

This function takes a name xxx and creates a module called mod_xxx.R in the R folder.

golem::add_module(name = "this")

The new file will contain:

# mod_UI
mod_this_ui <- function(id){
  ns <- NS(id)
  tagList(
  
  )
}

mod_this_server <- function(input, output, session){
  ns <- session$ns
}
    
## To be copied in the UI
# mod_this_ui("this1")
    
## To be copied in the server
# callModule(mod_this_server, "this1")
 

Add or change favicon

golem::use_favicon()
golem::use_favicon(path = "path/to/your/favicon.ico")

Add tests

Adds the recommended tests for a shiny app.

golem::use_recommended_tests()

app_prod

There’s a series of tools to make your app behave differently whether it’s in dev or prod mode. Notably, the app_prod() and app_dev() function tests for options( "golem.app.prod") (or return TRUE if this option doesn’t exist).

Setting this options at the beginning of your dev process allows to make your app behave in a specific way when you are in dev mode. For example, printing message to the console with cat_dev().

options( "golem.app.prod" = TRUE)
golem::cat_dev("hey\n")
options( "golem.app.prod" = FALSE)
golem::cat_dev("hey\n")
#> hey

You can then make any function being “dev-dependant” with the make_dev() function:

log_dev <- golem::make_dev(log)
log_dev(10)
#> [1] 2.302585
options( "golem.app.prod" = TRUE)
log_dev(10)

Quick reload and show application

see the run_dev.R file in the dev directory


# Detach all loaded packages and clean your environment
golem::detach_all_attached()
# rm(list=ls(all.names = TRUE))

# Document and reload your package
golem::document_and_reload()
mypkg::run_app()

Deployment tools

direct

Once the package (e.g. mypkg) is installed, the application can be launch with the following command.

mypkg::run_app()

rsconnect

This creates a simple file at the root of the package, to be used to deploy to RStudio Connect.

golem::add_rconnect_file()

docker ( for shinyproxy and other )

golem::add_dockerfile()

Tool series

This package is part of a series of tools for Shiny, which includes:

Know more

The Book :

Building big Shiny Apps :

Blog post :

https://rtask.thinkr.fr/blog/our-shiny-template-to-design-a-prod-ready-app

CoC

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Copy Link

Version

Down Chevron

Install

install.packages('golem')

Monthly Downloads

7,213

Version

0.0.1.5001

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

January 1st, 1970

Functions in golem (0.0.1.5001)