Where does RStudio store the temporary R script fi

2019-04-07 10:49发布

问题:

I've just had RStudio crash on me unexpectedly, and on re-starting, contrary to what I've come to expect, the R script I had been tinkering around with was nowhere to be found.

I've managed to track down the Rhistory file so I'll be able to piece together all the commands, which is reassuring.

However, I am curious if there's somewhere I might try looking to find the temporary unsaved file on the off chance that might be cached somewhere (after all, it is usually cached somewhere that RStudio apparently knows to look). Is there a particular file extension/format I should be searching for?

Currently running R 3.3.1 through RStudio 0.99.903 on Linux Mint 17.3 (over Ubuntu 14.04.3 LTS).


I've tried running grep on the command line to find some of the more recently updated lines of code; I may be out of luck. I found two files:

~/.rstudio-desktop/history_database

Which appears to basically be a more centralized .Rhistory for RStudio

and

~/.rstudio-desktop/sdb/s-9CD2C698/D7986B2A

This looks JSON-like and also appears to basically be an Rhistory. Please correct me if I'm wrong.

回答1:

As indicated by @KevinUshey from RStudio:

RStudio stores autosave data as part of the JSON 'blobs' within the sdb folder. You should see the document serialized as a long 'string', with newlines embedded.

Use packages such as jsonlite to parse this and best of luck.



标签: r rstudio