knitr::opts_chunk$set(echo = TRUE) library(dplyr) library(pkglite) library(purrr)
# Initiate start-up file source(file.path(rprojroot::find_root("DESCRIPTION"), "inst/startup.R"))
This document summarizes the preparation and installation instructions for the R Consortium Submission Pilot 2 Shiny application. Here is a brief description of the procedures:
{pkglite}
R package, with the intent of using this text file to submit the application through the FDA's submission portal based on the FDA's Electronic Common Technical Document (eCTD) format.{golem}
package, the application can be easily run with a single function call.The Shiny application in this pilot was created within R version 4.2.0, and the {renv}
package was used to manage the application dependencies to maintain a reproducible environment. All packages and their associated versions are listed in the table below.
pkg <- desc::desc_get_deps() %>% filter(type == "Imports") %>% pull(package) # custom code to obtain package title and version pkg_desc <- tibble::tibble(Package = pkg) %>% mutate(Title = purrr::map_chr(Package, ~utils::packageDescription(.x, fields = "Title"))) %>% mutate(Version = purrr::map_chr(Package, ~utils::packageDescription(.x, fields = "Version"))) %>% arrange(Package) pkg_desc
The code below assembles the application's code and supporting files into a custom text file using {pkglite}
and saved into ectd/r1pk1.txt
. Please note that the size of this text file is approximately 37 megabytes due to the included data sets within the application.
# specification for app.R file app_spec <- file_spec( ".", pattern = "\\.R$", format = "text", recursive = FALSE ) app_source_spec <- file_spec( "R", pattern = "\\.R", format = "text", recursive = FALSE ) renv_spec <- file_spec( ".", pattern = "\\.lock", format = "text", recursive = FALSE ) renv_spec2 <- file_spec( "renv", pattern = "\\.R$", format = "text", recursive = FALSE ) renv_spec3 <- file_spec( "renv/cellar", pattern = "\\.tar.gz|\\.zip", format = "binary", recursive = TRUE ) golem_spec <- file_spec( "dev", pattern = "^run", format = "text", recursive = FALSE ) file_ectd2 <- file_spec( ".", pattern = "^DESCRIPTION$|^NAMESPACE$|^README$|^README\\.md$|^NEWS$|^NEWS\\.md$|^LICENSE$|\\.Rbuildignore$|\\.Rprofile$|\\.Renviron$", format = "text", recursive = FALSE, ignore_case = FALSE, all_files = TRUE ) path$home %>% collate( file_ectd2, file_auto("inst"), app_spec, app_source_spec, renv_spec, renv_spec2, renv_spec3, golem_spec ) %>% pack(output = file.path(rprojroot::find_root("DESCRIPTION"), "vignettes/ectd/r1pkg.txt"))
To unpack the application source code and supporting files from the custom ectd/r1pkg.txt
bundle and run the Shiny application, perform the following steps in your preferred R development environment, such as RStudio or a R console session:
r1pkg.txt
file, and run the following code: pkglite::unpack(input = "r0pkg.txt", install = FALSE)
. You should see a series of messages indicating the application files being written to a subdirectory called pilot2wrappers
.pilot2wrappers
subdirectory. {renv}
by running the following code: renv::restore()
. After confirmation, the packages used by the application will be downloaded and installed in a project-specific library.app.R
file and click the Run App button at the top of the file window. If you are using an R console, run the following code: golem:::run_dev()
. Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.