Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the .RData file

Tags:

r

I realize that I overwrote an .R file that took me some time to create. Is it possible to see in my .RData the commands that I ran? I always saved my files as external scripts and have never used the .RData file before so I don't really know what to do and am afraid of loosing it forever.

like image 514
djq Avatar asked Jan 20 '11 04:01

djq


People also ask

What is in .RData file?

RData file contains all objects in your current workspace.

How do I read a .RData file?

The easiest way to load the data into R is to double-click on the particular file yourfile. RData after you download it to your computer. This will open in RStudio only if you have associated the . RData files with RStudio.

How do I load a saved R workspace?

To access file click File and then load workspace. A dialog box will appear, browse to the folder where you saved the . RData file and click open.


2 Answers

Do you have a file in your directory named ".Rhistory"? This file might be hidden on Linux systems.

Read up the help page ?history

like image 67
Mike T Avatar answered Sep 21 '22 14:09

Mike T


This is not really a direct answer to your question, but some advice from The Pragmatic Programmer that has served me well time and time again to avoid situations like this:

Always Use Source Code Control

If a process was worth the time it took to record the steps in a .R file, then it should be protected by a source code control system. This gives you many important benefits, two of which are:

  • You can recover or rewind your files which provides protection against accidental deletion or modifications that, an hour later, start to seem like they were not such a good idea after all.

  • Your work is backed up in one or more locations. Preferably on different computers.

If you have never used source code control before, here are some resources to get you started:

  • Git is a great system that has the benefit of being distributed which makes your files very hard to loose. gitref.org is a greate place to learn about Git and GitHub provides great hosting for off-site Git repositories.

  • Mercurial is another good distributed system. Joel Spolsky, one of the cofounders of this very site, wrote an excellent guide at hginit.com. Bitbucket is a great place to host off-site Mercurial repositories---they even allow unlimited private repositories if you need to control access to your work.

Learning source code control was without a doubt the most valuable investment I have ever made in a programming tool. It pays its self back the first time a situation like this comes up.

like image 37
Sharpie Avatar answered Sep 18 '22 14:09

Sharpie