MCredd - package creation steps
app-build.Rmd
#library(MCredd)
This page shows the different steps to create the package and the main function which is a shiny app, as well as how the app is loaded to shinyapp.io.
Main source for info:
- https://r-pkgs.org/
- https://rtask.thinkr.fr/building-a-shiny-app-as-a-package/
- https://mastering-shiny.org/scaling-packaging.html
Inital setup:
- Create a Github repository.
- Create a R project from Github (See https://happygitwithr.com/ on linking Github repos to Rstudio).
- Create a package structure inside he project:
-
usethis::create_package("PATH/MCredd")
with PATH the path to the project folder set during the project creation.
-
- Add vignettes and pkgdown setup:
usethis::use_pkgdown()
usethis::use_vignette("app-generation", title = "MCredd - package creation steps")
Barebone app
Add dependencies to DESCRIPTION:
- Analysis
usethis::use_package("magrittr")
usethis::use_package("readr")
usethis::use_package("tidyselect")
usethis::use_package("dplyr")
usethis::use_package("ggplot2")
#usethis::use_package("tibble")
#usethis::use_package("forcats")
usethis::use_package("purrr")
usethis::use_package("stringr")
usethis::use_package("rlang")
# usethis::use_package("tidyverse", type = "depends")
usethis::use_package("readxl")
- Shiny related
usethis::use_package("shiny")
usethis::use_package("shinyjs")
usethis::use_package("shinyWidgets")
usethis::use_package("bslib")
- Geospatial
usethis::use_package("sf")
usethis::use_package("terra")
usethis::use_package("units")
Run all the time:
devtools::document()
devtools::load_all()
shiny_run_MCredd()
devtools::install()
library(MCredd)
shiny_run_MCredd()