rstudio::conf(2020L)
## # A tibble: 11 x 2## data description ## <chr> <chr> ## 1 diamonds Prices of over 50,000 round cut diamonds ## 2 economics US economic time series ## 3 economics_l… US economic time series ## 4 faithfuld 2d density estimate of Old Faithful data ## 5 luv_colours 'colors()' in Luv space ## 6 midwest Midwest demographics ## 7 mpg Fuel economy data from 1999 to 2008 for 38 …## 8 msleep An updated and expanded version of the mamm…## 9 presidential Terms of 11 presidents from Eisenhower to O…## 10 seals Vector field of seal movements ## 11 txhousing Housing sales in TX
## # A tibble: 4 x 2## data description## <chr> <chr> ## 1 applicants Applicants.## 2 babynames Baby names.## 3 births Births ## 4 lifetables Lifetables
## # A tibble: 7 x 2## data description ## <chr> <chr> ## 1 character_visual… Counts of character speech, thought, na…## 2 characters Descriptions of character actions in th…## 3 comic_bechdel Whether or not an issue of another comi…## 4 covers Data on covers of issues of Uncanny X-M…## 5 issue_collaborat… Data about other collaborators on each …## 6 locations Locations of issues in the Claremont run## 7 xmen_bechdel Whether or not an issue of Uncanny X-Me…
use_data_raw()
use_data()
use_data(internal = TRUE)
data_dictionary <- tibble::tibble( database = "daily_active_users", variable = c("users", "sector"), description = c( "Active reactor-using households", "Midgar Sector #" ), )
use_data_raw("data_dictionary")
: data_dictionary.R
## code to prepare `data_dictionary` dataset goes hereusethis::use_data(data_dictionary, overwrite = TRUE)
use_data_raw("data_dictionary")
: data_dictionary.R
## code to prepare `data_dictionary` dataset goes heredata_dictionary <- tibble::tibble( database = "daily_active_users", variable = c("users", "sector"), description = c( "Active reactor-using households", "Midgar Sector #" ), )usethis::use_data(data_dictionary, overwrite = TRUE)
use_data_raw("data_dictionary")
: data_dictionary.R
## code to prepare `data_dictionary` dataset goes heredata_dictionary <- tibble::tibble( database = "daily_active_users", variable = c("users", "sector"), description = c( "Active reactor-using households", "Midgar Sector #" ), )usethis::use_data(data_dictionary, overwrite = TRUE)
library(shinRa)data_dictionary
## # A tibble: 2 x 3## database variable description ## <chr> <chr> <chr> ## 1 daily_active_users users Active reactor-using househol…## 2 daily_active_users sector Midgar Sector #
use_data_raw()
. Call the data "data_dictionary". In the data processing file, put this code before the use_data()
line. Then, source the script. This will run use_data()
for you.R/tables.R
. Add a function called gt_data_dictionary()
that wraps data_dictionary
in gt::gt()
. You can use gt_donations()
as a starting point for the new function.vignettes/data-dictionary.Rmd
. On line 24, run gt_data_dictionary()
and knit the vignette.use_data_raw("data_dictionary")source("data-raw/data_dictionary.R")
#' Create gt table for the data dictionary#'#' @return a `gt` table#' @exportgt_data_dictionary <- function() { gt::gt(data_dictionary)}
helper-
or test-
file.tests/testthat
use_data(internal = TRUE)
) use_data()
) template.yaml
name: Ninja Presentationdescription: > Create a presentation using the xaringan package based on remark.js.create_dir: false
skeleton.Rmd
template.yaml
name: Ninja Presentation (Simplified Chinese)description: > Create a presentation using the xaringan package based on remark.js. create_dir: true
## inst/rmarkdown/templates/xaringan_zh-CN/skeleton/## ├── skeleton.Rmd## └── zh-CN.css
use_rmarkdown_template()
. For the template_description
argument, set it to: "A weekly report of AVALANCHE activities."exercises/
folder, there is a file called report.Rmd
. Copy and paste its contents into inst/rmarkdown/templates/avalanche-report/skeleton/skeleton.Rmd
, which you just created.build()
or Cmd/Ctrl + Shift + B
).File > New File > R Markdown...
. Then, find your template under the "From Template" tab. Open it.use_rmarkdown_template( "template_description", "A weekly report of AVALANCHE activities.")
inst/
inst/
.inst/
inst/
.R/
or data/
.inst/
inst/
.R/
or data/
.system.file()
or fs::path_package()
system.file()
system.file( file.path("rmarkdown", "templates", "report.Rmd"), package = "shinRa", mustWork = TRUE)
system.file()
system.file( file.path("rmarkdown", "templates", "report.Rmd"), package = "shinRa", mustWork = TRUE)
## [1] "path/to/shinRa/rmarkdown/templates/report.Rmd"
use_cran_comments()
use_cran_comments()
use_cran_comments <- function(open = interactive()) { check_is_package("use_cran_comments()") use_template( "cran-comments.md", data = list(rversion = glue("{version$major}.{version$minor}")), ignore = TRUE, open = open )}
use_cran_comments()
use_cran_comments <- function(open = interactive()) { check_is_package("use_cran_comments()") use_template( "cran-comments.md", data = list(rversion = glue("{version$major}.{version$minor}")), ignore = TRUE, open = open )}
use_template()
and inst/templates
use_template()
and inst/templates
## # A tibble: 56 x 2## path type ## <chr> <fct>## 1 CODE_OF_CONDUCT.md file ## 2 Jenkinsfile file ## 3 Makefile file ## 4 NAMESPACE file ## 5 NEWS.md file ## 6 addins.dcf file ## 7 appveyor.yml file ## 8 article.Rmd file ## 9 azure-pipelines.yml file ## 10 circleci-config.yml file ## # … with 46 more rows
cran-comments.md
# ## Test environments# * local R installation, R {{{ rversion }}}# * ubuntu 16.04 (on travis-ci), R {{{ rversion }}}# * win-builder (devel)# # ## R CMD check results# # 0 errors | 0 warnings | 1 note# # * This is a new release.
whisker::whisker.render("## Test environments * local R installation, R {{{ rversion }}} * ubuntu 16.04 (on travis-ci), R {{{ rversion }}} * win-builder (devel) ## R CMD check results 0 errors | 0 warnings | 1 note * This is a new release.",data = list(rversion = glue::glue("{version$major}.{version$minor}")))
## ## Test environments## * local R installation, R 3.6.1 ## * ubuntu 16.04 (on travis-ci), R 3.6.1 ## * win-builder (devel)## ## ## R CMD check results## ## 0 errors | 0 warnings | 1 note## ## * This is a new release.
inst/templates/config.yml
inst/templates/config.yml
library(fs)dir_create(path("inst", "templates"))file_create(path("inst", "templates", "config.yml"))
inst/templates/config.yml
library(fs)dir_create(path("inst", "templates"))file_create(path("inst", "templates", "config.yml"))
In config.yml
:
name: {{{name}}} affiliation: Shinra, Inc.description: {{{description}}}
use_template()
use_yaml_template <- function(path, name, description) { usethis::use_template( "config.yml", save_as = file.path(path, "config.yml"), package = "shinRa", data = list(name = name, description = description) )}
use_yaml_template( ".", "Malcolm Barrett", "A project to analyze reactor data")
use_yaml_template( ".", "Malcolm Barrett", "A project to analyze reactor data")
## ✔ Writing '/var/folders/03/9x7925g54mncswxx06wpkxl0000...
use_yaml_template( ".", "Malcolm Barrett", "A project to analyze reactor data")
## ✔ Writing '/var/folders/03/9x7925g54mncswxx06wpkxl0000...
name: Malcolm Barrett affiliation: Shinra, Inc.description: A project to analyze reactor data
exercises/templates/
, there are three files: "packages.R", "analysis.R", and "report.Rmd". Open them up and take a look. Note that report.Rmd
has some whisker variables in the YAML!inst/templates
by running this code in the console: fs::dir_copy("exercises/templates/", "inst/templates")
R/create_analysis.R
. create_analysis()
is going to help us set up the project directory, but we need to complete it. In lines 22, 23, and 25, add the template names: "packages.R", "analysis.R", and "report.Rmd".data
argument takes a named list. For this argument, write:
list(author = author, title = title)`.create_analysis()
is a helper function, usethis::use_template()
, to create files from templates. Change the package
argument to "avalanchr".create_analysis()
in the console. If something went wrong, just delete the folder avalanche_analysis
and try again.create_analysis <- function(path = ".", folder = "avalanche_analysis", author = "Author", title = "Untitled Analysis") { analysis_path <- fs::path(path, folder) if (fs::dir_exists(analysis_path)) fs::dir_delete(analysis_path) usethis::ui_done("Writing {usethis::ui_path(folder)}") fs::dir_create(analysis_path) use_avalanche_template("packages.R", folder = folder) use_avalanche_template("analysis.R", folder = folder) use_avalanche_template( "report.Rmd", folder = folder, data = list(author = author, title = title) ) invisible(analysis_path)}
use_avalanche_template <- function(template, folder, data = list()) { usethis::use_template( template = template, save_as = fs::path(folder, template), data = data, package = "avalanchr" )}
create_analysis()
--
inst/shinyapps/
(or something similar)inst/shinyapps/
(or something similar)--
launch_app <- function(app) { app_dir <- system.file( "shinyapps", app, package = "shinRa", mustWork = TRUE ) shiny::runApp(app_dir)}
inst/shinyapps/
(or something similar)launch_app <- function(app) { app_dir <- system.file( "shinyapps", app, package = "shinRa", mustWork = TRUE ) shiny::runApp(app_dir)}
inst/shinyapps/
(or something similar)launch_app <- function(app) { app_dir <- system.file( "shinyapps", app, package = "shinRa", mustWork = TRUE ) shiny::runApp(app_dir)}
--
See "Supplementing your R package with a Shiny app" for more.
examples/
folder called plot_app/
. It has two Shiny files: ui.R
and server.R
.use_package("shiny")
inst/
called shinyapps
use_r()
called "launch_app".#' Launch Reactor Data Shiny App#'#' @return a shiny app#' @exportlaunch_app <- function() { app_dir <- system.file( "shinyapps", "shiny_reactor_report", package = "avalanchr", mustWork = TRUE ) shiny::runApp(app_dir)}
launch_app()
inst/
, the world is yoursinst/
, the world is yoursinst/scripts
and sys.source()
inst/
, the world is yoursinst/scripts
and sys.source()
inst/CITATION
inst/
, the world is yoursinst/scripts
and sys.source()
inst/CITATION
--
use_build_ignore()
: don't include when building R packageuse_build_ignore()
: don't include when building R packageuse_git_ignore()
: don't commit (credentials, certain rendered files, etc)use_build_ignore()
: don't include when building R packageuse_git_ignore()
: don't commit (credentials, certain rendered files, etc)git_vaccinate()
miniui
and RStudio.use_addin()
exercises/templates/
, there are three files: "packages.R", "analysis.R", and "report.Rmd". Open them up and take a look. Note that report.Rmd
has some whisker variables in the YAML!inst/templates
by running this code in the console: fs::dir_copy("exercises/templates/", "inst/templates")
R/create_analysis.R
. create_analysis()
is going to help us set up the project directory, but we need to complete it. In lines 22, 23, and 25, add the template names: "packages.R", "analysis.R", and "report.Rmd".data
argument takes a named list. For this argument, write:
list(author = author, title = title)`.create_analysis()
is a helper function, usethis::use_template()
, to create files from templates. Change the package
argument to "avalanchr".create_analysis()
in the console. If something went wrong, just delete the folder avalanche_analysis
and try again.create_analysis <- function(path = ".", folder = "avalanche_analysis", author = "Author", title = "Untitled Analysis") { analysis_path <- fs::path(path, folder) if (fs::dir_exists(analysis_path)) fs::dir_delete(analysis_path) usethis::ui_done("Writing {usethis::ui_path(folder)}") fs::dir_create(analysis_path) use_avalanche_template("packages.R", folder = folder) use_avalanche_template("analysis.R", folder = folder) use_avalanche_template( "report.Rmd", folder = folder, data = list(author = author, title = title) ) invisible(analysis_path)}
use_avalanche_template <- function(template, folder, data = list()) { usethis::use_template( template = template, save_as = fs::path(folder, template), data = data, package = "avalanchr" )}
create_analysis()
--
inst/shinyapps/
(or something similar)inst/shinyapps/
(or something similar)--
launch_app <- function(app) { app_dir <- system.file( "shinyapps", app, package = "shinRa", mustWork = TRUE ) shiny::runApp(app_dir)}
inst/shinyapps/
(or something similar)launch_app <- function(app) { app_dir <- system.file( "shinyapps", app, package = "shinRa", mustWork = TRUE ) shiny::runApp(app_dir)}
inst/shinyapps/
(or something similar)launch_app <- function(app) { app_dir <- system.file( "shinyapps", app, package = "shinRa", mustWork = TRUE ) shiny::runApp(app_dir)}
--
See "Supplementing your R package with a Shiny app" for more.
examples/
folder called plot_app/
. It has two Shiny files: ui.R
and server.R
.use_package("shiny")
inst/
called shinyapps
use_r()
called "launch_app".#' Launch Reactor Data Shiny App#'#' @return a shiny app#' @exportlaunch_app <- function() { app_dir <- system.file( "shinyapps", "shiny_reactor_report", package = "avalanchr", mustWork = TRUE ) shiny::runApp(app_dir)}
launch_app()
inst/
, the world is yoursinst/
, the world is yoursinst/scripts
and sys.source()
inst/
, the world is yoursinst/scripts
and sys.source()
inst/CITATION
inst/
, the world is yoursinst/scripts
and sys.source()
inst/CITATION
--
use_build_ignore()
: don't include when building R packageuse_build_ignore()
: don't include when building R packageuse_git_ignore()
: don't commit (credentials, certain rendered files, etc)use_build_ignore()
: don't include when building R packageuse_git_ignore()
: don't commit (credentials, certain rendered files, etc)git_vaccinate()
miniui
and RStudio.use_addin()
See "Shiny Gadgets" and "Designing Gadget UI"
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |