Explicitly Recording Packages
As with the previous exercise, it is recommended that you fork the repository to your GitHub account and clone it to your local machine to follow along with the examples. This will allow the course facilitators to see your work, provide feedback, and troubleshoot with you as needed.
If you’re not familiar with using git and GitHub, you can skip the forking and cloning steps and instead download a zip file of the repository.
Adding Packages to therenv.lock
File
The exercises for initiating and snapshotting a project can be found in the explicit-record-exercises
folder of the intro-to-renv-exercises repo.
Instructions
- Open the
explicit-record-exercises.Rproj
project. - Check the identified dependencies by running
renv::dependencies()
.- What packages are identified as direct dependencies and why?
- Initiate {renv} by running
renv::init()
. - Double-check the status of the dependencies by running
renv::status()
.- Is the lock file in-sync with the project library? (Hint: it should be.)
- Open the
analysis_doc.qmd
file and try to Render the analysis document.- Why did the rendering fail?
- Check the documentation for the
map_data()
function using?ggplot2::map_data
. What package is still needed?
- Explicitly record the needed package with
renv::record("package_name")
. - Check the status of the dependencies again by running
renv::status()
.- What has changed?
- Install the newly identified dependencies by running
renv::restore()
. - Open the
analysis_doc.qmd
file again, and Render the analysis document.- Was it successful this time?
- Why did you need to explicitly record one of the packages to be able to render the document?
- Take a look at the
DESCRIPTION
file for {ggplot2} to help understand:packageDescription("ggplot2")
.
- Take a look at the
- Close the
explicit-record-exercises.Rproj
project.