Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a "reader-friendly" sessionInfo() to text file

Tags:

r

I would like to save the output of "sessionInfo()" to a text file. Using "write()" failed because "list() cannot be handled by 'cat()'". I then tried "save()" with ascii = T but the resulting file is not really helpful.

I would like to have an output like this in a text file. Any easy, straightforward way to do this?

like image 218
roschu Avatar asked Feb 23 '14 10:02

roschu


People also ask

How do I write the contents of the reader to file?

First – we're reading the contents of the Reader into a String; then we're simply writing the String to File. 2. With Guava The Guava solution is simpler – we now have the API to deal with writing the reader to file:

What is screen-reader friendly writing style?

Writing in this screen-reader friendly style means you are writing in a screen-friendly style, which makes for a better user experience for all customers and visitors on all devices. Structure your content logically so that it can be easily navigated. Titles – use a clear title that describes the topic or purpose.

What is screen-friendly writing?

Writing in this screen-reader friendly style means you are writing in a screen-friendly style, which makes for a better user experience for all customers and visitors on all devices. Structure your content logically so that it can be easily navigated.


2 Answers

Capture the screen output into a character vector and use writeLines.

writeLines(capture.output(sessionInfo()), "sessionInfo.txt") 
like image 162
Roland Avatar answered Sep 23 '22 12:09

Roland


‘sink’ diverts R output to a connection. 


sink("sessionInfo.txt") sessionInfo() sink() 

sessionInfo.txt:

R version 3.0.2 (2013-09-25) Platform: x86_64-pc-linux-gnu (64-bit)  locale:  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C                [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8      [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8     [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                   [9] LC_ADDRESS=C               LC_TELEPHONE=C             [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C         attached base packages: [1] stats     graphics  grDevices utils     datasets  methods   base       loaded via a namespace (and not attached): [1] compiler_3.0.2 tools_3.0.2  
like image 33
Jake Burkhead Avatar answered Sep 25 '22 12:09

Jake Burkhead