Documentation and Reproducibility

Shiny

Brief description

Shiny is an R package for building interactive web apps straight from R. You can visit Shiny Website for the most useful resources on mastering shiny or look for help from RStudio Community or shinyapps-users Google group.

To ensure the Shiny app is deployed under a reproducible environment, there are two tools we can use: renv and Docker.

Long description

Official Documentation Resources

Getting Help

Shiny - Run the dashbaord in a reproducible way locally

To ensure the app is deployed under the same configuration as your local application, there are two tools we can use here.

1. {renv}

{renv} package allows one to have a project-based library so others can run the dashboard locally. To create a reproducible renv library, here are the steps to follow:

# Loading and initiating {renv}
library(renv)
init()
# Installing attempt
install.packages("attempt")
# Create a fake script that launches {attempt}
write("library(attempt)", "script.R")
# Snapshoting the current status of the environment
renv::snapshot(confirm = FALSE)

2. Docker

Docker is a program that allows to download, install, create, launch and stop multiple operating systems, called containers, on a machine, which will be called the host. This host can be your local computer, or the server where you deploy your application/s.

A. Building a Dockerfile with golem

For a golem project, you can run the following from the root of your package:

golem::add_dockerfile()

B. {dockerfiler}

You can use dockerfiler package to generate a Dockerfile straight from R

# Creating a new Dockerfile object
my_dock <- Dockerfile$new()
# Adding RUN, ADD, WORKDIR and EXPOSE commands
my_dock$RUN("apt-get update && apt-get install -y git-core")
my_dock$ADD(".", "/")
my_dock$RUN("mkdir /build_zone")
my_dock$ADD(".", "/build_zone")
my_dock$WORKDIR("/build_zone")
my_dock$RUN(r(remotes::install_local(upgrade="never")))
my_dock$EXPOSE(80)
# Viewing the Dockerfile
my_dock

C. Develop inside a Docker container

If you plan on using Docker as a deployment mechanism, you can also use Docker as a local developer environment.