Get access to all lessons in this course.
-
Setup packages
- devtools and usethis
- Package names and authors
- Choose a license
- Setup git + GitHub
-
Write code
- Writing functions
- Adding functions to our package
- Using other packages
- Packages so good they get their own functions
- Organizing .R files
-
Document
- roxygen2: In-Line Documentation for R
- Argument descriptions and examples
- Helper functions
- Joining documentation
-
Test
- Unit tests for R
- Organizing tests
- R CMD Check
- Types of Test Files
- Test Coverage
-
Teach
- Examples
- README
- Spellcheck
-
Add data and files
- Store data and files
- Include data for tests and create RMarkdown templates
- Create other templates
- Launch and store Shiny apps
- Citations, ignoring files, and including add-ins
Package Development with R
Create other templates
This lesson is locked
This lesson is called Create other templates, part of the Package Development with R course. This lesson is called Create other templates, part of the Package Development with R course.
Transcript
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”.
You need to be signed-in to comment on this post. Login.