# sessioncheck 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. ## Installation You can install the current CRAN release of sessioncheck with: ``` r install.packages("sessioncheck") ``` Alternatively, you can install the development version of sessioncheck from [GitHub](https://github.com/) with: ``` r # install.packages("pak") pak::pak("djnavarro/sessioncheck") ``` ## Example The intention when using **sessioncheck** is that you would rarely load it with [`library()`](https://rdrr.io/r/base/library.html). Instead, a single line of code like this would be added at the top of the script: ``` r 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](https://sessioncheck.djnavarro.net/articles/sessioncheck.html) 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()`](https://sessioncheck.djnavarro.net/reference/sessionstate.md) function that reports the current state of a session (most useful at the end of a script). ``` r sessioncheck::sessionstate() ``` The [`sessionstate()`](https://sessioncheck.djnavarro.net/reference/sessionstate.md) 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](https://sessioncheck.djnavarro.net/articles/sessionstate-reporting.html) page. # Package index ## Core functions Check and report the session state - [`sessioncheck()`](https://sessioncheck.djnavarro.net/reference/sessioncheck.md) : Checks the overall status of the R session - [`sessionstate()`](https://sessioncheck.djnavarro.net/reference/sessionstate.md) : Report the current state of the R session - [`compare_sessionstates()`](https://sessioncheck.djnavarro.net/reference/compare_sessionstates.md) : Compare two session state snapshots ## Session checkers Individual session check functions - [`check_globalenv_objects()`](https://sessioncheck.djnavarro.net/reference/check_globalenv_objects.md) : Check global environment objects - [`check_attached_environments()`](https://sessioncheck.djnavarro.net/reference/check_attached_environments.md) : Check environments attached to the search path - [`check_attached_packages()`](https://sessioncheck.djnavarro.net/reference/check_attached_packages.md) : Check attached packages - [`check_loaded_namespaces()`](https://sessioncheck.djnavarro.net/reference/check_loaded_namespaces.md) : Check loaded namespaces - [`check_sessiontime()`](https://sessioncheck.djnavarro.net/reference/check_sessiontime.md) : Check session run time - [`check_working_directory()`](https://sessioncheck.djnavarro.net/reference/check_working_directory.md) : Check the working directory - [`check_required_options()`](https://sessioncheck.djnavarro.net/reference/check_required_options.md) : Check required values for options - [`check_required_locale()`](https://sessioncheck.djnavarro.net/reference/check_required_locale.md) : Check required values for locale settings - [`check_required_sysenv()`](https://sessioncheck.djnavarro.net/reference/check_required_sysenv.md) : Check required values for system environment variables ## Methods S3 methods for session check classes - [`format(`*``*`)`](https://sessioncheck.djnavarro.net/reference/display_methods.md) [`format(`*``*`)`](https://sessioncheck.djnavarro.net/reference/display_methods.md) [`print(`*``*`)`](https://sessioncheck.djnavarro.net/reference/display_methods.md) [`print(`*``*`)`](https://sessioncheck.djnavarro.net/reference/display_methods.md) [`format(`*``*`)`](https://sessioncheck.djnavarro.net/reference/display_methods.md) [`print(`*``*`)`](https://sessioncheck.djnavarro.net/reference/display_methods.md) [`format(`*``*`)`](https://sessioncheck.djnavarro.net/reference/display_methods.md) [`print(`*``*`)`](https://sessioncheck.djnavarro.net/reference/display_methods.md) : Format and print sessioncheck objects - [`as.data.frame(`*``*`)`](https://sessioncheck.djnavarro.net/reference/coercion_methods.md) [`as.data.frame(`*``*`)`](https://sessioncheck.djnavarro.net/reference/coercion_methods.md) [`as.data.frame(`*``*`)`](https://sessioncheck.djnavarro.net/reference/coercion_methods.md) [`as.data.frame(`*``*`)`](https://sessioncheck.djnavarro.net/reference/coercion_methods.md) : Coerce session check object to a data frame # Articles ### Checking the R session state - [Why is it important to check the R session?](https://sessioncheck.djnavarro.net/articles/why-check-the-r-session.md): - [Customizing sessioncheck() behavior](https://sessioncheck.djnavarro.net/articles/customizing-sessioncheck.md): - [Individual session check functions](https://sessioncheck.djnavarro.net/articles/individual-checks.md): ### Reporting the R session state - [Reporting the session state](https://sessioncheck.djnavarro.net/articles/sessionstate-reporting.md): - [Comparing session states](https://sessioncheck.djnavarro.net/articles/sessionstate-comparison.md): - [Customizing sessionstate() output](https://sessioncheck.djnavarro.net/articles/sessionstate-display.md): ### Other topics - [S3 classes and methods](https://sessioncheck.djnavarro.net/articles/s3-classes.md):