Skip to content

Commit

Permalink
Merge pull request #30 from RConsortium/pkglite_fix
Browse files Browse the repository at this point in the history
Streamline pkglite bundle
  • Loading branch information
rpodcast authored Sep 1, 2022
2 parents ed520a8 + 7af6243 commit 395f52a
Show file tree
Hide file tree
Showing 15 changed files with 4,028 additions and 299,272 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ $run_dev.*
^app\.R$
^rsconnect$
^LICENSE\.md$
^datasets$
1 change: 1 addition & 0 deletions .Renviron
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RENV_PATHS_CELLAR="renv/cellar"
11 changes: 6 additions & 5 deletions R/app_teal.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#' @importFrom teal init modules module
#' @importFrom shiny tags
create_teal <- function() {
adsl <- haven::read_xpt(app_sys("adam", "adsl.xpt"))
adam_path <- get_golem_config("adam_path")
adsl <- haven::read_xpt(file.path(adam_path, "adsl.xpt"))
adsl <- adsl %>%
dplyr::mutate(
TRT01P = factor(TRT01P, levels = c("Placebo", "Xanomeline Low Dose", "Xanomeline High Dose")),
AGEGR1 = factor(AGEGR1, levels = c("<65", "65-80", ">80")),
RACE = factor(RACE, levels = c("WHITE", "BLACK OR AFRICAN AMERICAN", "AMERICAN INDIAN OR ALASKA NATIVE"))
)
adas <- haven::read_xpt(app_sys("adam", "adadas.xpt")) %>%
adas <- haven::read_xpt(file.path(adam_path, "adadas.xpt")) %>%
dplyr::filter(
EFFFL == "Y",
ITTFL == 'Y',
PARAMCD == 'ACTOT',
ANL01FL == 'Y'
)
adtte <- haven::read_xpt(app_sys("adam", "adtte.xpt")) %>%
adtte <- haven::read_xpt(file.path(adam_path, "adtte.xpt")) %>%
dplyr::filter(PARAMCD == "TTDE")
adlb <- haven::read_xpt(app_sys("adam", "adlbc.xpt")) %>%
adlb <- haven::read_xpt(file.path(adam_path, "adlbc.xpt")) %>%
subset(TRTPN %in% c(0, 81) & PARAMCD == "GLUC" & !is.na(AVISITN)) %>%
dplyr::mutate(TRTPN = ifelse(TRTPN == 0, 99, TRTPN)) # change treatment order for pairwise comparison

Expand Down Expand Up @@ -63,7 +64,7 @@ create_teal <- function() {
)

),
header = "Pilot2 app (draft)",
header = "Pilot2 Shiny Application",
footer = tags$p(class="text-muted", "Source: R Consortium")
)

Expand Down
2 changes: 1 addition & 1 deletion R/tm_g_kmplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ srv_g_kmplot <- function(input, output, session, datasets) {
output$plot <- renderPlot({
adsl <- datasets$get_data("ADSL", filtered = TRUE)
adtte <- datasets$get_data("ADTTE", filtered = TRUE)
anl <- adsl %>%
anl <<- adsl %>%
dplyr::filter(
SAFFL == "Y",
STUDYID == "CDISCPILOT01"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions dev/03_deploy.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
## Check the package before sending to prod
devtools::check()

# Build
## Buld the package tarball and send to the renv cellar directory

## Linux version
devtools::build(path = "renv/cellar")

## Windows version


# Install to renv library
renv::install("renv/cellar/pilot2wrappers_0.2.0.tar.gz")

# Deploy

## Local, CRAN or Package Manager ----
Expand Down
1 change: 1 addition & 0 deletions inst/golem-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ default:
golem_name: pilot2wrappers
golem_version: 0.0.0.9000
app_prod: no
adam_path: "datasets/adam"
production:
app_prod: yes
dev:
Expand Down
1 change: 0 additions & 1 deletion renv/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cellar/
library/
local/
lock/
Expand Down
Binary file added renv/cellar/pilot2wrappers_0.2.0.tar.gz
Binary file not shown.
13 changes: 8 additions & 5 deletions vignettes/adrg-prepare.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ 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/r0pkg.txt`. Please note that the size of this text file is approximately 37 megabytes due to the included data sets within the 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.

```{r}
# specification for app.R file
Expand All @@ -75,6 +75,8 @@ renv_spec2 <- file_spec(
recursive = FALSE
)
golem_spec <- file_auto("dev")
file_ectd2 <- file_spec(
".",
pattern = "^DESCRIPTION$|^NAMESPACE$|^README$|^README\\.md$|^NEWS$|^NEWS\\.md$|^LICENSE$|\\.Rbuildignore$|\\.Rprofile$",
Expand All @@ -90,16 +92,17 @@ path$home %>%
file_auto("inst"),
app_spec,
renv_spec,
renv_spec2
renv_spec2,
golem_spec
) %>%
pack(output = "ectd/r0pkg.txt")
pack(output = "ectd/r1pkg.txt")
```

## Application Installation (Dry run)

To unpack the application source code and supporting files from the custom `ectd/r0pkg.txt` bundle and run the Shiny applicaton, perform the following steps in your preferred R development environment, such as RStudio or a R console session:
To unpack the application source code and supporting files from the custom `ectd/r1pkg.txt` bundle and run the Shiny applicaton, 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 `r0pkg.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`.
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`.
1. Launch a new R session in the `pilot2wrappers` subdirectory.
1. 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.
1. 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()`.
Loading

0 comments on commit 395f52a

Please sign in to comment.