Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting the name of a dataframe from loading a .rda file in R

I am trying to load an .rda file in r which was a saved dataframe. I do not remember the name of it though.

I have tried

a<-load("al.rda")

which then does not let me do anything with a. I get the error

Error:object 'a' not found

I have also tried to use the = sign.

How do I load this .rda file so I can use it?

I restared R with load("al.rda) and I know get the following error

Error: C stack usage is too close to the limit
like image 920
megv Avatar asked Dec 17 '11 21:12

megv


1 Answers

Use 'attach' and then 'ls' with a name argument. Something like:

attach("al.rda")
ls("file:al.rda")

The data file is now on your search path in position 2, most likely. Do:

search()
ls(pos=2)

for enlightenment. Typing the name of any object saved in al.rda will now get it, unless you have something in search path position 1, but R will probably warn you with some message about a thing masking another thing if there is.

However I now suspect you've saved nothing in your RData file. Two reasons:

  1. You say you don't get an error message
  2. load says there's nothing loaded

I can duplicate this situation. If you do save(file="foo.RData") then you'll get an empty RData file - what you probably meant to do was save.image(file="foo.RData") which saves all your objects.

How big is this .rda file of yours? If its under 100 bytes (my empty RData files are 42 bytes long) then I suspect that's what's happened.

like image 54
Spacedman Avatar answered Sep 20 '22 00:09

Spacedman