R session information is important for documenting the computing environment that is used when running R scripts and reproducing the results of R scripts. With base R, you can use the sessionInfo()
function to obtain the session information:
> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
Matrix products: default
BLAS/LAPACK: /spack/apps/linux-centos7-x86_64/gcc-8.3.0/openblas-0.3.8-2no6mfziiclwxb7lstxoos335gnhjpes/lib/libopenblasp-r0.3.8.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_3.3.2 tidyr_1.1.1 dplyr_1.0.1 readr_1.3.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 withr_2.2.0 crayon_1.3.4 grid_4.0.0 R6_2.4.1
[6] gtable_0.3.0 lifecycle_0.2.0 magrittr_1.5 scales_1.1.1 pillar_1.4.6
[11] rlang_0.4.7 vctrs_0.3.2 generics_0.0.2 ellipsis_0.3.1 glue_1.4.1
[16] munsell_0.5.0 purrr_0.3.4 hms_0.5.3 compiler_4.0.0 colorspace_1.4-1
[21] pkgconfig_2.0.3 tidyselect_1.1.0 tibble_3.0.3
Alternatively, the sessioninfo
or devtools
packages both provide the same session_info()
function that gives more information in a different display format:
> session_info()
─ Session info ───────────────────────────────────────────────────────────────────────────────────
setting value
version R version 4.0.0 (2020-04-24)
os CentOS Linux 7 (Core)
system x86_64, linux-gnu
ui X11
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/Los_Angeles
date 2020-08-13
─ Packages ───────────────────────────────────────────────────────────────────────────────────────
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0)
cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.0)
colorspace 1.4-1 2019-03-18 [2] CRAN (R 4.0.0)
crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.0)
dplyr * 1.0.1 2020-07-31 [1] CRAN (R 4.0.0)
ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.0)
fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0)
generics 0.0.2 2018-11-29 [1] CRAN (R 4.0.0)
ggplot2 * 3.3.2 2020-06-19 [2] CRAN (R 4.0.0)
glue 1.4.1 2020-05-13 [1] CRAN (R 4.0.0)
gtable 0.3.0 2019-03-25 [2] CRAN (R 4.0.0)
hms 0.5.3 2020-01-08 [2] CRAN (R 4.0.0)
lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.0)
magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.0)
munsell 0.5.0 2018-06-12 [2] CRAN (R 4.0.0)
pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.0)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.0)
purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.0)
R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.0)
Rcpp 1.0.5 2020-07-06 [2] CRAN (R 4.0.0)
readr * 1.3.1 2018-12-21 [2] CRAN (R 4.0.0)
rlang 0.4.7 2020-07-09 [1] CRAN (R 4.0.0)
scales 1.1.1 2020-05-11 [2] CRAN (R 4.0.0)
sessioninfo * 1.1.1 2018-11-05 [2] CRAN (R 4.0.0)
tibble 3.0.3 2020-07-10 [1] CRAN (R 4.0.0)
tidyr * 1.1.1 2020-07-31 [1] CRAN (R 4.0.0)
tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.0)
vctrs 0.3.2 2020-07-15 [1] CRAN (R 4.0.0)
withr 2.2.0 2020-04-20 [2] CRAN (R 4.0.0)
[1] /home1/user/R/x86_64-pc-linux-gnu-library/4.0
[2] /spack/apps/linux-centos7-x86_64/gcc-8.3.0/r-4.0.0-jfy3icn4kexk7kyabcoxuio2iyyww3o7/rlib/R/library
You can save the output of these functions into a plain-text file by using the following line of code in an R script (after loading all packages):
writeLines(capture.output(session_info()), "session_info.txt")