MichaelChirico
MichaelChirico

Reputation: 34763

Where does RStudio store the temporary R script files before saved?

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.

Upvotes: 14

Views: 13465

Answers (3)

Cristhian Diaz
Cristhian Diaz

Reputation: 26

In Rstudio if you saved or not a script but you ran this code, you can check the history off the app, this is the "telemetric data" that Rstudio has about you.

In windows, this is the path,

C:\Users\ANALISTA\AppData\Local\RStudio\history_database

you should use "visual studio code" or something similar to see it.

Upvotes: 0

Zhihao Huang
Zhihao Huang

Reputation: 1

if you used Rstudio on linux, the temporary R script files were stored in .rstudio/sources folder, and you can open all of the script files directly. Good luck

Upvotes: 0

MichaelChirico
MichaelChirico

Reputation: 34763

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.

Upvotes: 7

Related Questions