Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: Reduce sessionInfo output

Tags:

r

sessionInfo() prints the below:

R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] ggmap_2.7.900       gdtools_0.1.7       bindrcpp_0.2        crosstalk_1.0.0    
 [5] leaflet_1.1.0       networkD3_0.4       d3heatmap_0.6.1.2   dygraphs_1.1.1.4   
 [9] ggiraph_0.4.2       plotly_4.7.1        ggplot2_2.2.1.9000  highcharter_0.5.0  
[13] formattable_0.2.0.1 DT_0.4              kableExtra_0.7.0    stringr_1.3.0      
[17] tidyr_0.8.0         dplyr_0.7.4         markdown_0.8        bookdown_0.7       
[21] rmarkdown_1.9       knitr_1.20         

loaded via a namespace (and not attached):
 [1] nlme_3.1-131.1      bitops_1.0-6        xts_0.10-2          devtools_1.13.5    
 [5] lubridate_1.7.3     RColorBrewer_1.1-2  httr_1.3.1          rprojroot_1.3-2    
 [9] tools_3.4.3         backports_1.1.2     R6_2.2.2            lazyeval_0.2.1     
[13] colorspace_1.3-2    sp_1.2-7            withr_2.1.2         mnormt_1.5-5       
[17] git2r_0.21.0        curl_3.1            compiler_3.4.3      rvest_0.3.2        
[21] xml2_1.2.0          officer_0.2.2       labeling_0.3        scales_0.5.0.9000  
[25] psych_1.7.8         readr_1.1.1         digest_0.6.15       foreign_0.8-69     
[29] R.utils_2.6.0       jpeg_0.1-8          base64enc_0.1-3     pkgconfig_2.0.1    
[33] htmltools_0.3.6     maps_3.2.0          highr_0.6           rvg_0.1.8          
[37] htmlwidgets_1.0     rlang_0.2.0.9001    TTR_0.23-3          quantmod_0.4-12    
[41] xaringan_0.6        shiny_1.0.5         bindr_0.1.1         zoo_1.8-1          
[45] jsonlite_1.5        zip_1.0.0           R.oo_1.21.0         magrittr_1.5       
[49] rlist_0.4.6.1       geosphere_1.5-7     Rcpp_0.12.16        munsell_0.4.3      
[53] proto_1.0.0         R.methodsS3_1.7.1   stringi_1.1.7       yaml_2.1.18        
[57] plyr_1.8.4          grid_3.4.3          parallel_3.4.3      lattice_0.20-35    
[61] mapproj_1.2-5       hms_0.4.2           pillar_1.2.1        igraph_1.2.1       
[65] uuid_0.1-2          rjson_0.2.15        reshape2_1.4.3      glue_1.2.0         
[69] evaluate_0.10.1     data.table_1.10.4-3 png_0.1-7           httpuv_1.3.6.2     
[73] RgoogleMaps_1.4.1   gtable_0.2.0        purrr_0.2.4         assertthat_0.2.0   
[77] xfun_0.1            mime_0.5            xtable_1.8-2        broom_0.4.3        
[81] viridisLite_0.3.0   tibble_1.4.2        memoise_1.1.0  

This is too much information. How can I skip the last category (loaded via a namespace (and not attached):) ?

like image 933
rmf Avatar asked Jan 21 '26 04:01

rmf


1 Answers

You can remove an item from sessionInfo(), which is a list with a class attribute then use the relevant method to print the resulting object:

getS3method("print","sessionInfo")(sessionInfo()[-7])
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C                   LC_TIME=French_France.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] data.table_1.10.4 tidytext_0.1.8    bindrcpp_0.2      dplyr_0.7.4       readr_1.1.1       tidyr_0.7.2      
 [7] tibble_1.3.4      ggplot2_2.2.1     tidyverse_1.1.1   purrr_0.2.4       grofit_1.1.1-1    swirl_2.4.3      
[13] lobstr_0.0.0.9000 Rcpp_0.12.16      rlang_0.2.0

This also works with same output:

utils:::print.sessionInfo(sessionInfo()[-7]) # thanks @r2evans

or

`class<-`(sessionInfo()[-7],"sessionInfo")

To know which part to remove from output, check:

names(sessionInfo())
 [1] "R.version"  "platform"   "locale"     "running"    "basePkgs"   "otherPkgs"  "loadedOnly" "matprod"    "BLAS"      
[10] "LAPACK"
like image 69
Moody_Mudskipper Avatar answered Jan 23 '26 19:01

Moody_Mudskipper