Skip to content
R for the Rest of Us Logo

Create other templates

This lesson is locked

Get access to all lessons in this course.

If the video is not playing correctly, you can watch it in a new window


Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Your Turn

  • 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”.

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.