CRAN packages can be easily installed using the install.packages function. For example, the stringr package provides a set of modern functions for manipulating and formatting strings.
To use stringr, we first need to install the package typing into your script or console:
install.packages("stringr")
and click run or hit return, respectively. If your user account has permission to install packages then you should see something like:
trying URL 'https://cloud.r-project.org/bin/macosx/big-sur-arm64/contrib/4.4/stringr_1.5.1.tgz'
Content type 'application/x-gzip' length 314273 bytes (306 KB)
==================================================
downloaded 306 KB
The downloaded binary packages are in
/var/folders/bq/2w1p57q54r78thfjpfy2cbrc0000gp/T//RtmpQ8lR4N/downloaded_packages
Notice that this will automatically get the right package for your operating system (in this example macosx). Also note that you only have to do this once, as once installed, this package is already available. If you have permission issues installing new packages in your system, you can try installing them in your user space with
You can update all packages for which updates are available using update.packages(). You can add the option update.packages(ask=FALSE) to update everything without prompting. Note that updating all of your packages could take a while if you haven’t done it recently.
update.packages()
boot :
Version 1.3-30 installed in /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library
Version 1.3-31 available at https://cran.rstudio.com
Update? (Yes/no/cancel)
Updates and reproducibility
Software updates can pose challenges for reproducibility. It’s important to document and track the specific versions of software and packages used. renv is a package management tool for R that helps create reproducible environments.