Initializing a new project

Create a new RMarkdown (Rmd) file in RStudio

Your RMarkdown file should be in its own directory (with no other .Rmd files).

Install renv

  1. Install renv using the instructions on the RStudio site (if not already installed)

  2. Navigate to the directory where your Rmd file is located and initialize a new renv project.

    setwd("path/to/directory")
    renv::init()
    
    

Install IRkernel

IRkernel is necessary for Pathbird to run your notebook.

renv::settings$snapshot.type("all")
renv::install("IRkernel")
renv::snapshot()
# note: you do NOT need to run IRkernel::installspec() here

<aside> 💡 Even though you won't use IRkernel while developing your lesson it must be installed (since Pathbird uses IRkernel to run student code). Pathbird can't install it automatically since it might accidentally upgrade one of the dependencies of your project.

</aside>

<aside> 👉 IMPORTANT: Make sure to run the renv::settings$snapshot.type("all") command. This tells renv to record all of the dependencies, not just the ones you directly use in your R code. This is important to ensure that renv keeps track of the IRkernel dependency.

</aside>

Create your document as normal

You can install any packages (using either renv::install or install.packages) and write your R code as normal. Remember to save your environment (by running renv::snapshot()) after installing new packages.

See the Codex syntax reference for a reference on how to add Pathbird-specific directives into your file.

Troubleshooting

IRkernel is not installed

Make sure your renv snapshot mode is set to all and that you've installed IRkernel into your project:

renv::settings$snapshot.type("all")
install.packages("IRkernel")