diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..66ba948 --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,4 @@ +^.*\.Rproj$ +^\.Rproj\.user$ +^Dockerfile$ +^\.dockerignore$ diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6d593f8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.RData +.Rhistory +.git +.gitignore +manifest.json +rsconnect/ +.Rproj.user + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d864844 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata +.DS_Store + + +data/deadcounter.rds +data/efscounter.rds diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..80b7f74 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM --platform=linux/amd64 rocker/verse:4.4.1 +RUN apt-get update && apt-get install -y libcairo2-dev libcurl4-openssl-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libharfbuzz-dev libicu-dev libjpeg-dev libpng-dev libssl-dev libtiff-dev libxml2-dev make pandoc zlib1g-dev && rm -rf /var/lib/apt/lists/* +RUN mkdir -p /usr/local/lib/R/etc/ /usr/lib/R/etc/ +RUN echo "options(repos = c(CRAN = 'https://cran.rstudio.com/'), download.file.method = 'libcurl', Ncpus = 4)" | tee /usr/local/lib/R/etc/Rprofile.site | tee /usr/lib/R/etc/Rprofile.site +RUN R -e 'install.packages("remotes")' +RUN Rscript -e 'remotes::install_version("bslib",upgrade="never", version = "0.5.0")' +RUN Rscript -e 'remotes::install_version("shiny",upgrade="never", version = "1.7.5.1")' +RUN Rscript -e 'remotes::install_version("rmarkdown",upgrade="never", version = "2.23")' +RUN Rscript -e 'remotes::install_version("config",upgrade="never", version = "0.3.2")' +RUN Rscript -e 'remotes::install_version("waiter",upgrade="never", version = "0.2.5")' +RUN Rscript -e 'remotes::install_version("shinyjs",upgrade="never", version = "2.1.0")' +RUN Rscript -e 'remotes::install_version("shinyBS",upgrade="never", version = "0.61.1")' +RUN Rscript -e 'remotes::install_version("nftbart",upgrade="never", version = "2.1")' +RUN Rscript -e 'remotes::install_version("golem",upgrade="never", version = "0.4.1")' +RUN Rscript -e 'remotes::install_version("ggplot2",upgrade="never", version = "3.4.3")' +RUN Rscript -e 'remotes::install_version("flextable",upgrade="never", version = "0.9.6")' +RUN Rscript -e 'remotes::install_version("fastDummies",upgrade="never", version = "1.7.3")' +RUN Rscript -e 'remotes::install_version("DT",upgrade="never", version = "0.33")' +RUN mkdir /build_zone +ADD . /build_zone +WORKDIR /build_zone +RUN R -e 'remotes::install_local(upgrade="never")' +RUN rm -rf /build_zone +EXPOSE 80 +ENV RDS_DATA /efsdata + +CMD R -e "remotes::install_local(upgrade=\"never\");options('shiny.port'=80,shiny.host='0.0.0.0');library(nmdp.asom);nmdp.asom::run_app()" diff --git a/NAMESPACE b/NAMESPACE index daa9501..6ae9268 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,23 +1,2 @@ # Generated by roxygen2: do not edit by hand -export(run_app) -import(bslib) -import(flextable) -import(ggplot2) -import(nftbart) -import(shiny) -import(shinyBS) -import(shinyjs) -import(waiter) -importFrom(golem,activate_js) -importFrom(golem,add_resource_path) -importFrom(golem,bundle_resources) -importFrom(golem,favicon) -importFrom(golem,with_golem_options) -importFrom(shiny,HTML) -importFrom(shiny,NS) -importFrom(shiny,column) -importFrom(shiny,shinyApp) -importFrom(shiny,tagAppendAttributes) -importFrom(shiny,tagList) -importFrom(shiny,tags) diff --git a/R/app_ui.R b/R/app_ui.R index 34801ac..4b02c54 100644 --- a/R/app_ui.R +++ b/R/app_ui.R @@ -9,14 +9,16 @@ waiter::waiter_set_theme(html = waiter::spin_3() options(mc.cores = 8) +data_directory = Sys.getenv("RDS_DATA", "data") + # load data: -zcta_hhinc <- readRDS(file = "data/zcta_hhinc.RDS") -patdat_default <- readRDS(file = "data/patdat_default.RDS") -xtest_names <- readRDS(file = "data/xtest_vnames.RDS") -dat_fmtfun <- readRDS(file = "data/dat_fmtfun.RDS") - -nft_os <- readRDS(file = "data/deadcounter.rds") -nft_efs <- readRDS(file = "data/efscounter.rds") +zcta_hhinc <- readRDS(file = paste0(data_directory, "/zcta_hhinc.RDS")) +patdat_default <- readRDS(file = paste0(data_directory, "/patdat_default.RDS")) +xtest_names <- readRDS(file = paste0(data_directory, "/xtest_vnames.RDS")) +dat_fmtfun <- readRDS(file = paste0(data_directory, "/dat_fmtfun.RDS")) + +nft_os <- readRDS(file = paste0(data_directory, "/deadcounter.rds")) +nft_efs <- readRDS(file = paste0(data_directory, "/efscounter.rds")) #' The application User-Interface #' diff --git a/README.Rmd b/README.Rmd index ec79b85..faa0a57 100644 --- a/README.Rmd +++ b/README.Rmd @@ -2,10 +2,10 @@ title: "README for nmdp.asom" author: "Lisa Rein" date: "2024-08-23" -output: html_document +output: md_document --- -```{r } +``` # set working directory to R project for nmdp.asom app # working directory should be wherever app.R is housed: @@ -25,7 +25,10 @@ list.files(paste0(mydir, "/data")) # To run the app: # Note the model objects are large and the initial load could take a long time: library(shiny) +# Run and time startup +Sys.time() shiny::runApp() +Sys.time() # you should see a message in the console if the app is successfully loading: 'Loading nmdp.asom' diff --git a/README.md b/README.md new file mode 100644 index 0000000..f082ace --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +``` +# set working directory to R project for nmdp.asom app +# working directory should be wherever app.R is housed: +mydir <- "Z:/consulting/Logan_Brent/nmdp.asom" +setwd(mydir) + +list.files(mydir) + +# make sure that model objects deadcounter.rds and efscounter.rds are saved in data folder: +list.files(paste0(mydir, "/data")) + +# To run the app: +# Note the model objects are large and the initial load could take a long time: +library(shiny) +# Run and time startup +Sys.time() +shiny::runApp() +Sys.time() + +# you should see a message in the console if the app is successfully loading: 'Loading nmdp.asom' + +# Dependent packages should automatically be installed/loaded but just in case, +# app dependencies (also noted in NAMESPACE): +# import(bslib) +# import(flextable) +# import(ggplot2) +# import(nftbart) +# import(shiny) +# import(shinyBS) +# import(shinyjs) +# import(waiter) +# importFrom(golem,activate_js) +# importFrom(golem,add_resource_path) +# importFrom(golem,bundle_resources) +# importFrom(golem,favicon) +# importFrom(golem,with_golem_options) +# importFrom(shiny,HTML) +# importFrom(shiny,NS) +# importFrom(shiny,column) +# importFrom(shiny,shinyApp) +# importFrom(shiny,tagAppendAttributes) +# importFrom(shiny,tagList) +# importFrom(shiny,tags) +``` diff --git a/nmdp.asom.Rproj b/nmdp.asom.Rproj index 38501bf..1e19eab 100644 --- a/nmdp.asom.Rproj +++ b/nmdp.asom.Rproj @@ -1,23 +1,23 @@ -Version: 1.0 - -RestoreWorkspace: No -SaveWorkspace: No -AlwaysSaveHistory: No - -EnableCodeIndexing: No -UseSpacesForTab: Yes -NumSpacesForTab: 4 -Encoding: UTF-8 - -RnwWeave: Sweave -LaTeX: pdfLaTeX - -AutoAppendNewline: Yes -StripTrailingWhitespace: Yes -LineEndingConversion: Posix - -BuildType: Package -PackageUseDevtools: Yes -PackageInstallArgs: --no-multiarch --with-keep.source - -QuitChildProcessesOnExit: Yes +Version: 1.0 + +RestoreWorkspace: No +SaveWorkspace: No +AlwaysSaveHistory: No + +EnableCodeIndexing: No +UseSpacesForTab: Yes +NumSpacesForTab: 4 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes +LineEndingConversion: Posix + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source + +QuitChildProcessesOnExit: Yes