# Initiate start-up file
source(file.path(rprojroot::find_root("DESCRIPTION"), "inst/startup.R"))
knitr::opts_chunk$set(echo = TRUE)

library(dplyr)
library(pkglite)

Pack Proprietary R Analysis Package

Using pkglite to pack proprietary R package and saved into ectd/r0pkg.txt.

path$home %>%
  collate(file_ectd(), file_auto("inst")) %>%
  prune("R/zzz.R") %>%
  pack(output = "ectd/r0pkg.txt")
## -- Packing into pkglite file ---------------------------------------------------
## -- Reading package: pilot1wrappers ---------------------------------------------
## Reading ".Rbuildignore"
## Reading "DESCRIPTION"
## Reading "NAMESPACE"
## Reading "NEWS.md"
## Reading "README.md"
## Reading "R/eff_models.R"
## Reading "R/fmt.R"
## Reading "R/helpers.R"
## Reading "R/package.R"
## Reading "R/Tplyr_helpers.R"
## Reading "man/efficacy_models.Rd"
## Reading "man/fmt_ci.Rd"
## Reading "man/fmt_est.Rd"
## Reading "man/fmt_num.Rd"
## Reading "man/fmt_pval.Rd"
## Reading "man/nest_rowlabels.Rd"
## Reading "man/num_fmt.Rd"
## Reading "man/pad_row.Rd"
## Reading "man/pilot1wrappers-package.Rd"
## Reading "inst/pkgdown/assets/readme.txt"
## Reading "inst/pkgdown/templates/readme.txt"
## Reading "inst/startup.R"
## Writing to: "ectd/r0pkg.txt"

Prepare Submission Analysis Progam

Transfer Rmarkdown file to txt files and saved in ectd folder.

  • (optional) Review and remove unecessary information. For example:
knitr::include_graphics("pdf/tlf-efficacy.pdf")
  • (optional) Add header to help reviewer rerun code. For example:
# Note to Reviewer 
# To rerun the code below, please refer ADRG appendix.
# After required package are installed. 
# The path variable needs to be defined by using example code below
#
# path = list(adam = "path/to/esub/analysis/adam/datasets")     # Modify path to the actual location
# path$output = "."                                             # Output saved in current folder
knitr::purl("tlf-demographic.Rmd", output = "ectd/tlf-demographic.r")
knitr::purl("tlf-efficacy.Rmd",    output = "ectd/tlf-efficacy.r")
knitr::purl("tlf-kmplot.Rmd", output = "ectd/tlf-kmplot.r")
knitr::purl("tlf-primary.Rmd", output = "ectd/tlf-primary.r")

List R package for analysis

pkg <- c("pkglite","haven", "dplyr", "tidyr", "emmeans", "r2rtf","rtables", 
         "ggplot2", "cowplot", "visR",
         "Tplyr", "pharmaRTF", "huxtable", "stringr")

available.packages(contriburl = contrib.url(repos)) %>% 
  data.frame() %>% 
  subset(Package %in% pkg) %>% 
  select(Package, Version, Repository) %>%
  arrange(Package)
##             Package Version
## Tplyr         Tplyr   0.4.1
## cowplot     cowplot   1.1.1
## dplyr         dplyr   1.0.7
## emmeans     emmeans   1.6.3
## ggplot2     ggplot2   3.3.5
## haven         haven   2.4.3
## huxtable   huxtable   5.4.0
## pharmaRTF pharmaRTF   0.1.3
## pkglite     pkglite   0.2.0
## r2rtf         r2rtf   0.3.0
## rtables     rtables   0.3.8
## stringr     stringr   1.4.0
## tidyr         tidyr   1.1.3
## visR           visR   0.2.0
##                                                            Repository
## Tplyr     https://packagemanager.posit.co/cran/2021-08-31/src/contrib
## cowplot   https://packagemanager.posit.co/cran/2021-08-31/src/contrib
## dplyr     https://packagemanager.posit.co/cran/2021-08-31/src/contrib
## emmeans   https://packagemanager.posit.co/cran/2021-08-31/src/contrib
## ggplot2   https://packagemanager.posit.co/cran/2021-08-31/src/contrib
## haven     https://packagemanager.posit.co/cran/2021-08-31/src/contrib
## huxtable  https://packagemanager.posit.co/cran/2021-08-31/src/contrib
## pharmaRTF https://packagemanager.posit.co/cran/2021-08-31/src/contrib
## pkglite   https://packagemanager.posit.co/cran/2021-08-31/src/contrib
## r2rtf     https://packagemanager.posit.co/cran/2021-08-31/src/contrib
## rtables   https://packagemanager.posit.co/cran/2021-08-31/src/contrib
## stringr   https://packagemanager.posit.co/cran/2021-08-31/src/contrib
## tidyr     https://packagemanager.posit.co/cran/2021-08-31/src/contrib
## visR      https://packagemanager.posit.co/cran/2021-08-31/src/contrib

Proprietary Package

tribble(~ Package, ~ Version, 
        "pilot1wrappers", "0.1.1")
## # A tibble: 1 × 2
##   Package        Version
##   <chr>          <chr>  
## 1 pilot1wrappers 0.1.1

Dry run

  • Install pilot1wrappers from ectd/r0pkg.txt.
pkglite::unpack(input = "ectd/r0pkg.txt", output = tempdir(), install = TRUE)
  • Rerun other analysis scripts in ectd.
list.files("ectd")
## [1] "r0pkg.txt"         "tlf-demographic.r" "tlf-efficacy.r"   
## [4] "tlf-kmplot.r"      "tlf-primary.r"