11 min read

R session info info

Matt Dray (@mattdray)

US Attorney-General Jeff Sessions-Info (via Giphy)

US Attorney-General Jeff Sessions-Info (via Giphy)

What’s session info?

Session info is just some details about your working environment like your version of R, the locale it’s running from and any loaded packages.

It gives a snapshot to help people reproduce what you’ve done or spot any anomalies. You might get asked for this if someone is diagnosing your R problem. You may also see it at the end of blog posts or reports.

You would typically print this to the console with the base function sessionInfo(), but it gives a lot of information by default. Other functions have been created to make the output more friendly.

Why?

I’ve been using sessionInfo() in my posts, but read about Yihui’s session_info() function in his xfun package and saw Mat at machinegurning.com using session_info() from devtools.

I just want to see the outputs side-by-side for my own curiosity.

Load packages

Let’s grab some packages from different sources to see how they’re represented in the output of each function.

We’ll get some packages from:

# From CRAN
# install.packages("package-name")
library("dplyr")
library("purrr")
library("tidyxl")

# Dev versions of packages from rOpenSci
# devtools::install_github("github-user/package")
library("rfishbase")
library("rgbif")
library("helminthR")

# Bioconductor
source("https://bioconductor.org/biocLite.R")
biocLite()
biocLite(c("GenomicFeatures", "AnnotationDbi"))
## 
## The downloaded binary packages are in
##  /var/folders/y5/ts9sjlt10x1d7qpkgbhy3smh0000gn/T//RtmpT1t9Vj/downloaded_packages

The functions

utils

From the documentation for the function:

Print version information about R, the OS and attached or loaded packages.

What do you get? Loads of stuff:

  • R version, plaform and OS
  • matrix products, BLAS and LAPACK
  • locale (where you’re running R from)
  • packages – attached base packages, other attached packages, and loaded packages via namespace (but not attached) in separate sections with their version numbers

Maybe that’s too much stuff. Also I don’t really know what the BLAS and LAPACK stuff is; something to do with linear algebra. There’s also no notation to say where the packages came from (CRAN, GitHub or Bioconductor). But it’s pretty human-readable.

utils::sessionInfo()
## R version 3.5.1 (2018-07-02)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS High Sierra 10.13.6
## 
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] BiocInstaller_1.30.0 helminthR_1.0.6      rgbif_1.0.5.9100    
## [4] rfishbase_2.99       tidyxl_1.0.3         purrr_0.2.5         
## [7] dplyr_0.7.8         
## 
## loaded via a namespace (and not attached):
##  [1] tidyselect_0.2.5  xfun_0.3          reshape2_1.4.3   
##  [4] lattice_0.20-35   colorspace_1.3-2  htmltools_0.3.6  
##  [7] yaml_2.1.19       rlang_0.3.0.1     pillar_1.3.0     
## [10] glue_1.3.0        sp_1.3-1          bindrcpp_0.2.2   
## [13] jpeg_0.1-8        bindr_0.1.1       plyr_1.8.4       
## [16] stringr_1.3.1     rgeos_0.3-28      munsell_0.5.0    
## [19] blogdown_0.7      gtable_0.2.0      rvest_0.3.2      
## [22] RgoogleMaps_1.4.2 mapproj_1.2.6     memoise_1.1.0    
## [25] evaluate_0.10.1   knitr_1.20        proto_1.0.0      
## [28] Rcpp_1.0.0        geosphere_1.5-7   readr_1.1.1      
## [31] backports_1.1.2   scales_1.0.0      oai_0.2.2        
## [34] jsonlite_1.5      rjson_0.2.20      ggplot2_3.1.0    
## [37] hms_0.4.2         png_0.1-7         digest_0.6.18    
## [40] stringi_1.2.4     bookdown_0.7      grid_3.5.1       
## [43] rprojroot_1.3-2   tools_3.5.1       maps_3.3.0       
## [46] magrittr_1.5      lazyeval_0.2.1    tibble_1.4.2     
## [49] crayon_1.3.4      whisker_0.3-2     pkgconfig_2.0.2  
## [52] data.table_1.11.8 xml2_1.2.0        assertthat_0.2.0 
## [55] rmarkdown_1.10    geoaxe_0.1.0      httr_1.3.1       
## [58] R6_2.3.0          ggmap_2.6.1       compiler_3.5.1

devtools package

From the documentation for the function:

This is sessionInfo() re-written from scratch to both exclude data that’s rarely useful (e.g., the full collate string or base packages loaded) and include stuff you’d like to know (e.g., where a package was installed from).

What do you get? You get basically what’s in sessionInfo()

  • sections split into ‘session info’ and ‘packages’
  • version, system, UI, language, locale, timezone and date
  • package names with version number, date and source (CRAN, Bioconductor, Github, local)

It’s even more human-readable in the packages section, where the output is in table format and in alphabetical order. In particular, there’s a column to tell you where the package came from. For example, see how the helminthR package is from github (ropensci/helminthR@435371d) and there’s an asterisk in the row to show you it’ was attached.’s been attached in the session.

devtools::session_info()
## Session info -------------------------------------------------------------
##  setting  value                       
##  version  R version 3.5.1 (2018-07-02)
##  system   x86_64, darwin15.6.0        
##  ui       X11                         
##  language (EN)                        
##  collate  en_GB.UTF-8                 
##  tz       Europe/London               
##  date     2018-12-09
## Packages -----------------------------------------------------------------
##  package       * version    date       source                             
##  assertthat      0.2.0      2017-04-11 CRAN (R 3.5.0)                     
##  backports       1.1.2      2017-12-13 CRAN (R 3.5.0)                     
##  base          * 3.5.1      2018-07-05 local                              
##  bindr           0.1.1      2018-03-13 CRAN (R 3.5.0)                     
##  bindrcpp        0.2.2      2018-03-29 CRAN (R 3.5.0)                     
##  BiocInstaller * 1.30.0     2018-05-01 Bioconductor                       
##  blogdown        0.7        2018-07-07 CRAN (R 3.5.0)                     
##  bookdown        0.7        2018-02-18 CRAN (R 3.5.0)                     
##  colorspace      1.3-2      2016-12-14 CRAN (R 3.5.0)                     
##  compiler        3.5.1      2018-07-05 local                              
##  crayon          1.3.4      2017-09-16 CRAN (R 3.5.0)                     
##  data.table      1.11.8     2018-09-30 cran (@1.11.8)                     
##  datasets      * 3.5.1      2018-07-05 local                              
##  devtools        1.13.6     2018-06-27 CRAN (R 3.5.0)                     
##  digest          0.6.18     2018-10-10 cran (@0.6.18)                     
##  dplyr         * 0.7.8      2018-11-10 CRAN (R 3.5.0)                     
##  evaluate        0.10.1     2017-06-24 CRAN (R 3.5.0)                     
##  geoaxe          0.1.0      2016-02-19 cran (@0.1.0)                      
##  geosphere       1.5-7      2017-11-05 cran (@1.5-7)                      
##  ggmap           2.6.1      2016-01-23 cran (@2.6.1)                      
##  ggplot2         3.1.0      2018-10-25 CRAN (R 3.5.0)                     
##  glue            1.3.0      2018-07-17 CRAN (R 3.5.0)                     
##  graphics      * 3.5.1      2018-07-05 local                              
##  grDevices     * 3.5.1      2018-07-05 local                              
##  grid            3.5.1      2018-07-05 local                              
##  gtable          0.2.0      2016-02-26 CRAN (R 3.5.0)                     
##  helminthR     * 1.0.6      2018-10-11 Github (ropensci/helminthR@435371d)
##  hms             0.4.2      2018-03-10 CRAN (R 3.5.0)                     
##  htmltools       0.3.6      2017-04-28 CRAN (R 3.5.0)                     
##  httr            1.3.1      2017-08-20 CRAN (R 3.5.0)                     
##  jpeg            0.1-8      2014-01-23 cran (@0.1-8)                      
##  jsonlite        1.5        2017-06-01 CRAN (R 3.5.0)                     
##  knitr           1.20       2018-02-20 CRAN (R 3.5.0)                     
##  lattice         0.20-35    2017-03-25 CRAN (R 3.5.1)                     
##  lazyeval        0.2.1      2017-10-29 CRAN (R 3.5.0)                     
##  magrittr        1.5        2014-11-22 CRAN (R 3.5.0)                     
##  mapproj         1.2.6      2018-03-29 cran (@1.2.6)                      
##  maps            3.3.0      2018-04-03 cran (@3.3.0)                      
##  memoise         1.1.0      2017-04-21 CRAN (R 3.5.0)                     
##  methods       * 3.5.1      2018-07-05 local                              
##  munsell         0.5.0      2018-06-12 CRAN (R 3.5.0)                     
##  oai             0.2.2      2016-11-24 cran (@0.2.2)                      
##  pillar          1.3.0      2018-07-14 CRAN (R 3.5.0)                     
##  pkgconfig       2.0.2      2018-08-16 cran (@2.0.2)                      
##  plyr            1.8.4      2016-06-08 CRAN (R 3.5.0)                     
##  png             0.1-7      2013-12-03 CRAN (R 3.5.0)                     
##  proto           1.0.0      2016-10-29 cran (@1.0.0)                      
##  purrr         * 0.2.5      2018-05-29 CRAN (R 3.5.0)                     
##  R6              2.3.0      2018-10-04 cran (@2.3.0)                      
##  Rcpp            1.0.0      2018-11-07 CRAN (R 3.5.0)                     
##  readr           1.1.1      2017-05-16 CRAN (R 3.5.0)                     
##  reshape2        1.4.3      2017-12-11 CRAN (R 3.5.0)                     
##  rfishbase     * 2.99       2018-10-11 Github (ropensci/rfishbase@8a79450)
##  rgbif         * 1.0.5.9100 2018-10-11 Github (ropensci/rgbif@ad5cf5c)    
##  rgeos           0.3-28     2018-06-08 cran (@0.3-28)                     
##  RgoogleMaps     1.4.2      2018-06-08 cran (@1.4.2)                      
##  rjson           0.2.20     2018-06-08 cran (@0.2.20)                     
##  rlang           0.3.0.1    2018-10-25 CRAN (R 3.5.0)                     
##  rmarkdown       1.10       2018-06-11 CRAN (R 3.5.0)                     
##  rprojroot       1.3-2      2018-01-03 CRAN (R 3.5.0)                     
##  rvest           0.3.2      2016-06-17 CRAN (R 3.5.0)                     
##  scales          1.0.0      2018-08-09 CRAN (R 3.5.0)                     
##  sp              1.3-1      2018-06-05 CRAN (R 3.5.0)                     
##  stats         * 3.5.1      2018-07-05 local                              
##  stringi         1.2.4      2018-07-20 CRAN (R 3.5.0)                     
##  stringr         1.3.1      2018-05-10 CRAN (R 3.5.0)                     
##  tibble          1.4.2      2018-01-22 CRAN (R 3.5.0)                     
##  tidyselect      0.2.5      2018-10-11 CRAN (R 3.5.0)                     
##  tidyxl        * 1.0.3      2018-06-21 CRAN (R 3.5.0)                     
##  tools           3.5.1      2018-07-05 local                              
##  utils         * 3.5.1      2018-07-05 local                              
##  whisker         0.3-2      2013-04-28 CRAN (R 3.5.0)                     
##  withr           2.1.2      2018-03-15 CRAN (R 3.5.0)                     
##  xfun            0.3        2018-07-06 CRAN (R 3.5.0)                     
##  xml2            1.2.0      2018-01-24 CRAN (R 3.5.0)                     
##  yaml            2.1.19     2018-05-01 CRAN (R 3.5.0)

sessioninfo package

From the CRAN page for the package:

It is similar to utils::sessionInfo(), but includes more information about packages, and where they were installed from.

What do you get? Basically the same as utils::sessionInfo(). Note that the final column of output – the source column is wrapped below.

sessioninfo::session_info()
## ─ Session info ──────────────────────────────────────────────────────────
##  setting  value                       
##  version  R version 3.5.1 (2018-07-02)
##  os       macOS High Sierra 10.13.6   
##  system   x86_64, darwin15.6.0        
##  ui       X11                         
##  language (EN)                        
##  collate  en_GB.UTF-8                 
##  ctype    en_GB.UTF-8                 
##  tz       Europe/London               
##  date     2018-12-09                  
## 
## ─ Packages ──────────────────────────────────────────────────────────────
##  package       * version    date       lib
##  assertthat      0.2.0      2017-04-11 [1]
##  backports       1.1.2      2017-12-13 [1]
##  bindr           0.1.1      2018-03-13 [1]
##  bindrcpp        0.2.2      2018-03-29 [1]
##  BiocInstaller * 1.30.0     2018-05-01 [1]
##  blogdown        0.7        2018-07-07 [1]
##  bookdown        0.7        2018-02-18 [1]
##  cli             1.0.1      2018-09-25 [1]
##  colorspace      1.3-2      2016-12-14 [1]
##  crayon          1.3.4      2017-09-16 [1]
##  data.table      1.11.8     2018-09-30 [1]
##  devtools        1.13.6     2018-06-27 [1]
##  digest          0.6.18     2018-10-10 [1]
##  dplyr         * 0.7.8      2018-11-10 [1]
##  evaluate        0.10.1     2017-06-24 [1]
##  geoaxe          0.1.0      2016-02-19 [1]
##  geosphere       1.5-7      2017-11-05 [1]
##  ggmap           2.6.1      2016-01-23 [1]
##  ggplot2         3.1.0      2018-10-25 [1]
##  glue            1.3.0      2018-07-17 [1]
##  gtable          0.2.0      2016-02-26 [1]
##  helminthR     * 1.0.6      2018-10-11 [1]
##  hms             0.4.2      2018-03-10 [1]
##  htmltools       0.3.6      2017-04-28 [1]
##  httr            1.3.1      2017-08-20 [1]
##  jpeg            0.1-8      2014-01-23 [1]
##  jsonlite        1.5        2017-06-01 [1]
##  knitr           1.20       2018-02-20 [1]
##  lattice         0.20-35    2017-03-25 [1]
##  lazyeval        0.2.1      2017-10-29 [1]
##  magrittr        1.5        2014-11-22 [1]
##  mapproj         1.2.6      2018-03-29 [1]
##  maps            3.3.0      2018-04-03 [1]
##  memoise         1.1.0      2017-04-21 [1]
##  munsell         0.5.0      2018-06-12 [1]
##  oai             0.2.2      2016-11-24 [1]
##  pillar          1.3.0      2018-07-14 [1]
##  pkgconfig       2.0.2      2018-08-16 [1]
##  plyr            1.8.4      2016-06-08 [1]
##  png             0.1-7      2013-12-03 [1]
##  proto           1.0.0      2016-10-29 [1]
##  purrr         * 0.2.5      2018-05-29 [1]
##  R6              2.3.0      2018-10-04 [1]
##  Rcpp            1.0.0      2018-11-07 [1]
##  readr           1.1.1      2017-05-16 [1]
##  reshape2        1.4.3      2017-12-11 [1]
##  rfishbase     * 2.99       2018-10-11 [1]
##  rgbif         * 1.0.5.9100 2018-10-11 [1]
##  rgeos           0.3-28     2018-06-08 [1]
##  RgoogleMaps     1.4.2      2018-06-08 [1]
##  rjson           0.2.20     2018-06-08 [1]
##  rlang           0.3.0.1    2018-10-25 [1]
##  rmarkdown       1.10       2018-06-11 [1]
##  rprojroot       1.3-2      2018-01-03 [1]
##  rstudioapi      0.7        2017-09-07 [1]
##  rvest           0.3.2      2016-06-17 [1]
##  scales          1.0.0      2018-08-09 [1]
##  sessioninfo     1.1.0      2018-09-25 [1]
##  sp              1.3-1      2018-06-05 [1]
##  stringi         1.2.4      2018-07-20 [1]
##  stringr         1.3.1      2018-05-10 [1]
##  tibble          1.4.2      2018-01-22 [1]
##  tidyselect      0.2.5      2018-10-11 [1]
##  tidyxl        * 1.0.3      2018-06-21 [1]
##  whisker         0.3-2      2013-04-28 [1]
##  withr           2.1.2      2018-03-15 [1]
##  xfun            0.3        2018-07-06 [1]
##  xml2            1.2.0      2018-01-24 [1]
##  yaml            2.1.19     2018-05-01 [1]
##  source                             
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  Bioconductor                       
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  Github (ropensci/helminthR@435371d)
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.1)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  Github (ropensci/rfishbase@8a79450)
##  Github (ropensci/rgbif@ad5cf5c)    
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
##  CRAN (R 3.5.0)                     
## 
## [1] /Library/Frameworks/R.framework/Versions/3.5/Resources/library

xfun package

From Yihui Xie’s Introduction to xfun page:

…it is rarely useful to print out the names of base R packages, or information about the matrix products / BLAS / LAPACK. Often times I want additional information in the session information, such as the Pandoc version when rmarkdown is used.

What do you get? Basically utils::sessionInfo() but no matrix products, BLAS or LAPACK info, plus all the packages are listed together with their version numbers. You also can’t see where the package came from (CRAN, Github or Bioconductor). It lacks some human-readability compared to the functions in devtools and sessioninfo, but is clearly enough for Yihui – his package contains ‘miscellaneous functions that [he] use[s] by [him]self from time to time’.

xfun::session_info()
## R version 3.5.1 (2018-07-02)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS High Sierra 10.13.6
## 
## Locale: en_GB.UTF-8 / en_GB.UTF-8 / en_GB.UTF-8 / C / en_GB.UTF-8 / en_GB.UTF-8
## 
## Package version:
##   assertthat_0.2.0     backports_1.1.2      base64enc_0.1.3     
##   BH_1.66.0.1          bindr_0.1.1          bindrcpp_0.2.2      
##   BiocInstaller_1.30.0 blogdown_0.7         bookdown_0.7        
##   cli_1.0.1            colorspace_1.3-2     compiler_3.5.1      
##   crayon_1.3.4         crul_0.6.0           curl_3.2            
##   data.table_1.11.8    devtools_1.13.6      digest_0.6.18       
##   dplyr_0.7.8          evaluate_0.10.1      fansi_0.4.0         
##   geoaxe_0.1.0         geosphere_1.5-7      ggmap_2.6.1         
##   ggplot2_3.1.0        git2r_0.23.0         glue_1.3.0          
##   graphics_3.5.1       grDevices_3.5.1      grid_3.5.1          
##   gtable_0.2.0         helminthR_1.0.6      highr_0.7           
##   hms_0.4.2            htmltools_0.3.6      httpcode_0.2.0      
##   httpuv_1.4.4.2       httr_1.3.1           jpeg_0.1-8          
##   jsonlite_1.5         knitr_1.20           labeling_0.3        
##   later_0.7.3          lattice_0.20-35      lazyeval_0.2.1      
##   magrittr_1.5         mapproj_1.2.6        maps_3.3.0          
##   markdown_0.8         MASS_7.3.50          Matrix_1.2.14       
##   memoise_1.1.0        methods_3.5.1        mgcv_1.8.24         
##   mime_0.6             munsell_0.5.0        nlme_3.1.137        
##   oai_0.2.2            openssl_1.0.1        pillar_1.3.0        
##   piton_0.1.1          pkgconfig_2.0.2      plogr_0.2.0         
##   plyr_1.8.4           png_0.1-7            promises_1.0.1      
##   proto_1.0.0          purrr_0.2.5          R6_2.3.0            
##   RColorBrewer_1.1.2   Rcpp_1.0.0           readr_1.1.1         
##   reshape2_1.4.3       rfishbase_2.99       rgbif_1.0.5.9100    
##   rgeos_0.3-28         RgoogleMaps_1.4.2    rjson_0.2.20        
##   rlang_0.3.0.1        rmarkdown_1.10       rprojroot_1.3-2     
##   rstudioapi_0.7       rvest_0.3.2          scales_1.0.0        
##   selectr_0.4.1        servr_0.10           sessioninfo_1.1.0   
##   sp_1.3-1             stats_3.5.1          stringi_1.2.4       
##   stringr_1.3.1        tibble_1.4.2         tidyselect_0.2.5    
##   tidyxl_1.0.3         tinytex_0.5          tools_3.5.1         
##   triebeard_0.3.0      urltools_1.7.1       utf8_1.1.4          
##   utils_3.5.1          viridisLite_0.3.0    whisker_0.3-2       
##   wicket_0.4.0         withr_2.1.2          xfun_0.3            
##   xml2_1.2.0           yaml_2.1.19

Conclusion

Yep, they basically do the same thing with slight differences. I personally like the idea of having some kind of table-like output for easy readability, so I’ll probably go with devtools as I often have it loaded anyway.