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"))

Introduction

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:

Application Dependencies and Environment

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

Pack Shiny Application

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"))

Application Installation (Dry run)

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:

  1. Ensure that the working directory is set to the same location as the downloaded 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.
  2. Launch a new R session in the pilot2wrappers subdirectory.
  3. Ensure that the package library is restored with {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.
  4. To run the application, you have the following choices. If you are using RStudio to view the application, open the 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().


RConsortium/submissions-pilot2 documentation built on Feb. 7, 2025, 1:24 a.m.