Working in R and RStudio
A package masks the function of another package I use**
select()
from {dplyr} being masked by select()
from {MASS}A package masks the function of another package I use**
select()
from {dplyr} being masked by select()
from {MASS}load libraries in reverse order of importance.
select()
will be prioritised over the one from {MASS}.A package masks the function of another package I use**
select()
from {dplyr} being masked by select()
from {MASS}if you only need a single function from another package, call the function directly, rather than loading the entire library.
i.e. run MASS::lm.gls()
rather than library(MASS); lm.gls()
.
the double colon ::
enables you to access a library’s. functions without loading the entire library.
namespacing
Preventative measures:
load all libraries you need at the top of your scripts
this helps you control the order things are loaded and possible function masking
makes it clear to anyone else running the script what the dependencies are
When introducing a new package to your script
add it to the top of the script
restart your R session so it is clean
start re-running your code to make sure everything still works as expected
if it doesn’t, make sure its the first library to be loaded, and try again in a fresh R session
The package I used 1 year ago no longer exists
There are archives of packages, like MRAN, that will likely help you. But you’ll need to know which version you used, etc.
Can be tricky, but the {checkpoint} package might be of great assistance!
one of the first
a little complicated to use, requiring some knowledge of package paths etc.
new and widely used
creates fairly simple procedures to follow
can become complicated in some situations
renv should be used in projects
If you initiate renv when your not in a project, it will create one for you.
To initiate renv:
It looks in all project files for:
library(package)
require(package)
requireNamespace("package")
package::function()
Will also look for packages listed in the DESCRIPTON
file, as “Depends”, or “Imports”.
Explore the changes {renv} makes to a project.
Read the README.md to get started.
15:00