-1

I am writing multiple RDA files to my computer and trying to open them again. For example, I save a data frame called 'geocode' as:

dim(geocode)
save(geocode, file=paste0("[path]/geocodenew.Rda"))

I can see the file saved, about 30 KB, on my computer. But then I try to access it later I get:

load("[path]/geocodenew.Rda")
geocodenew

And I get the error:

"Error: object 'geocodenew' not found."

What am I doing wrong?

(I am eventually going to use this to stack multiple dataframes using rbind() if that helps at all)

989
  • 12,579
  • 5
  • 31
  • 53
garson
  • 1,505
  • 3
  • 22
  • 56
  • 1
    the name in the environment after `load` shld be just `geocode` if that's what it was when you `save`d it. Do `(load("[path]/geocodenew.Rda"))` and see what you get printed to the console. – hrbrmstr Jul 04 '15 at 15:46
  • Thank you for responding. Uh oh though. In retrospect a bad idea, but after saving geocodenew.Rda I re-made geocode as a NEW FILE and saved that to geocodenewer.Rda. Is there any way to recover both of these? – garson Jul 04 '15 at 15:54
  • 1
    load them into separate sessions or look at the `environment` parameter for `load` and load one of them into a new/separate environment – hrbrmstr Jul 04 '15 at 15:56
  • Actually, I figured it out!! Your advice was just what I needed to hear. I should be referencing 'geocode' not 'geocodenew.' Thanks – garson Jul 04 '15 at 15:56

1 Answers1

2

You can use saveRDS if you would like to save a specific object with a specific filename. e.g. saveRDS(geocode, file=paste0('path/geocodenew.rds') and then to read it back in geocodenew <- readRDS('path/geocodenew.rds').

Chris Watson
  • 1,347
  • 1
  • 9
  • 24