简体   繁体   中英

RStudio: Save data from Viewer

Due to a stupid mistake and a defective USB stick I lost a bunch of data and I am now trying to recover it.

Some of the the data is still displayed in the Viewer tabs when I open RStudio. However, I can only save R Scripts and R Markdownfiles out of the Viewer. The displayed data frames are nice and complete, I can sort and filter them in the Viewer, however, I cannot find a "save" option. Is there a possibility to save this displayed data into Rdata or csv or something similar?

I would suggest three different approaches, but none of them will necessarily work. I sort them according to my prior expectations of success.

1) You can copy all your data frame from the viewer and paste it into an external spreadsheet software to obtain a .csv file. Eg through the "convert text to columns" button in MS Excel.
2) You can copy and paste the character string into an object that is passed to the text option of read.table or to dput() . Check out the "Copy your data" section of this famous SO question
3) Finally, you can get google Chrome's "Inspect Element" function to inspect the html code of the object in the viewer. Once you find the table you can copy paste and scrape with an html parser, eg using the rvest package . Good luck!

Thanks everybody, there is a way to access the data as Rdata files, which was kindly explained to me here: https://support.rstudio.com/hc/en-us/community/posts/218065947-Recover-data-from-Viewer-tabs

I used the second method and located the files in %localappdata%\\RStudio-Desktop\\viewer-cache .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM