The primary goal of sessioncheck is to provide simple tools that can
be called at the top of a script, and produce warnings or errors if it
detects signs that the script is not being executed in a clean R
session. The intended user for sessioncheck is a beginner or
intermediate level R user who needs a drop-in replacement for the simple
but unsafe method of calling rm(list = ls()) at the top of the script.
As a secondary goal, it also provides some reporting tools that can be
useful for describing the state of an R session.
You can install the current CRAN release of sessioncheck with:
install.packages("sessioncheck")Alternatively, you can install the development version of sessioncheck from GitHub with:
# install.packages("pak")
pak::pak("djnavarro/sessioncheck")The intention when using sessioncheck is that you would rarely load
it with library(). Instead, a single line of code like this would be
added at the top of the script:
sessioncheck::sessioncheck()The default behavior is to check for objects in the global environment and to check packages and environments attached to the search path and produce a warning if issues are detected. This can be converted to an error if a stricter check is required, and additional checks can be added if desired. For details on how the checks work and how they can be customized see the get started page.
In addition to providing tools to check the session state (most useful
at the start of a script), the package also supplies a sessionstate()
function that reports the current state of a session (most useful at the
end of a script).
sessioncheck::sessionstate()The sessionstate() function is similar in spirit to session
information functions provided by base R and other packages. For details
on the similarities and differences between them see the session state
reporting
page.