How do I restore my saved session? (Clicked save session - okay - asked for project name - then GONE)

I'm new to R-Studio. I did a bunch of work, followed some tutorials. I saved my session, it then asked for a project directory name (I never selected "new project"), and then it auto-reloaded, and all my work is gone. The save session said okay before that project name dialog came up by itself (automatically, immediately after the save). I haven't touched anything since then. How do I get my work back?

Thanks for any help.

Hi @Mike4: What OS are you using?

Windows 10. It has always automatically updated with the latest updates.

What happens if you use File Explorer to try to locate one of the missing files? Do you remember any of their names? And if so, what folder does it show up in?

The only missing files would be session files, and I don't know their names. I know where the .csv file is I was using (Downloads). I was doing different things with the data, loading different libraries, and there was a scrollable history of my past commands that I kept reviewing. That is all gone.

The reason I ask is that is that when a new project is opened (which sounds like is what happened without you meaning to), a new directory may be created and everything --- including history --- may look as if you've started from scratch. Could you search for all the .RData files on your machine? That might give you a clue as to how to get back to where you were.

1 Like

Hi. I definitely did not select create new project. I specifically avoided that. I'm going to do a search for .RData files, and I will be back in a few minutes.

There was a single .RData file, in My Documents (not where the new project is). It is dated yesterday, and it's 827KB. I closed R-Studio, and it didn't ask me if I wanted to save anything. I double clicked on the .RData file, selected selected the option to open the file with R-Studio. R-Studio opened in an apparently clean state, with no history. -- I'm going to do another search for those files with Notepad++, because of how Microsoft destroyed it's search functionality 2-3 versions ago (Windows 8?).

History would be an .Rhistory file, which you can open from within RStudio in the 'History' tab.

1 Like

Thank you. All my history is there. Is there an easy way to add this session to the new project that I created?

If you're in the project on RStudio, you should be able to click on the 'History' tab in the upper right pane, and click the 'open folder'-looking icon to load it.

You also might want to make sure that you're saving history by default -- could you select Tools > Global Options... and post a screenshot?

Thanks @Mike4 -- it's set to save history, but I can see in the very upper right that you're not in a project ('Project: (None)'), and in the upper left I can see that you're in your home directory ('~/'). Anything you do from this point on will be saved in that directory, unless you change it explicitly.

Projects a good way to keep you work all in one place -- had you meant to create a new one?

I opened the .RData file I found with R-Studio, with R-Studio not running. I knew I was not in that project. My question is can I copy the .RData and .RHistory into that project, and then open that project. If not, I have the commands saved externally now (text document). So I have what I needed. I will will be in a open project when working with R-Studio from now on.

The simplest way would be to open your new project in RStudio first, then use the 'Environment' and 'History' tab to load the .RData and .Rhistory files you want. Could you try that?

I has able to load both the history and environment into the new project. Thanks.
--- And, the new project doesn't know what corrplot is, so I'm going to have to go through and issue all the commands again.

1 Like

That's a different issue: Every time you open a project you have to reload all the packages you need. One way to speed things up is to create a R file that only has the packages you use often, like

library(tidyverse)
library(corrplot)
... (more)

and if you keep it open, it'll be right there to load them when you need them.

1 Like

Thanks for that tip.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.