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.res_dictionary <- tibble::tibble( database = "residents_per_sector", variable = c("sector", "residents"), description = c( "Midgar Sector #", "Number of residents" ) ) reactor_dictionary <- tibble::tibble( database = "shinra_reactor_output", variable = c("reactor", "day", "output"), description = c( "Reactor ID", "Day of year (integer)", "Reactor output (gigawatts)" ) ) donations_dictionary <- tibble::tibble( database = "donations", variable = c("donor_id", "sector", "donation"), description = c( "Donor ID", "Midgar Sector # of donor residence", "Donation amount (gil)" ) ) data_dictionary <- dplyr::bind_rows(res_dictionary, reactor_dictionary, donations_dictionary)
Open 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.
Re-document and re-build the package.
Open vignettes/data-dictionary.Rmd
. On line 24, run gt_data_dictionary()
and knit the vignette.
Create a new R Markdown template called "avalanche-report" using use_rmarkdown_template()
. For the template_description
argument, set it to: "A weekly report of AVALANCHE activities."
Inside the 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.
Re-build the package (build()
or Cmd/Ctrl + Shift + B
).
Create a new R Markdown document using File > New File > R Markdown...
. Then, find your template under the "From Template" tab. Open it.
Let's create a usethis-style function to help set up analysis projects.
In the folder 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!
Copy the files to inst/templates
by running this code in the console: fs::dir_copy("exercises/templates/", "inst/templates")
Open 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".
Remember that "report.Rmd" has data to whisk. We need to tell it what to pass to the final file. The data
argument takes a named list. For this argument, write:
list(author = author, title = title)`.
Below create_analysis()
is a helper function, usethis::use_template()
, to create files from templates. Change the package
argument to "avalanchr".
Re-build your package and run create_analysis()
in the console. If something went wrong, just delete the folder avalanche_analysis
and try again.
There is an app in the examples/
folder called shiny_reactor_report/
. It has two Shiny files: ui.R
and server.R
.
Copy the shiny app to inst
by running this code in the console: fs::dir_copy("exercises/shiny_reactor_report/", "inst/shinyapps/shiny_reactor_report")
Run use_package("shiny")
Create an R file with use_r()
called "launch_app".
Write a function to launch the app
Add a roxygen skeleton and add a title and describe any parameters you used (if you used any)
Re-build your package and launch the app with your function
use_data_raw()
and use_data()
help add data to your packageuse_rmarkdown_templates()
generates boilerplate for an R Markdown template that gets included with your packageinst/
is a place to put extra files, and usethis has special support for templates in the inst/templates
folder. Create new templates with edit_template()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.