[R] Unable to load an object

Henrik Bengtsson hb at stat.berkeley.edu
Fri Jun 11 16:34:02 CEST 2010


If file 'geoFeatures.RData' contains an object with name
'"geoFeatures', it is loaded if you do:

load("geoFeatures.RData");

However, when you do:

geoFeatures <- load("geoFeatures.RData");

it will be loaded, but immediately overwritten because you create a
new object with the same name.  Note that load() returns a character
vector of the object *names* loaded.

Here is an example illustrating what is going on:

> x <- 1;
> save(x, file="foo.RData");
> rm(x);

> res <- load("foo.RData");
> res
[1] "x"
> str(x);
 num 1

> x <- load("foo.RData");
> str(x);
 chr "x"

You can easily load your data file into a new environment as:

> library("R.utils");
> env <- loadToEnv("foo.RData");

Then 'env' will be an environment containing your data, e.g.

> ll(envir=env);
  member data.class dimension objectSize
1      x    numeric         1         32

See also saveObject() and loadObject() in R.utils.

/Henrik
On Fri, Jun 11, 2010 at 4:15 PM, Joris Meys <jorismeys at gmail.com> wrote:
> Read the posting guide please.
>
> You can perfectly save and load the RData file. You just didn't save
> what you think you saved, but why that is can only be solved when we
> get to see your actual code.
>
> Cheers
> Joris
>
> On Fri, Jun 11, 2010 at 10:28 AM, Luis Ridao Cruz <Luisr at hav.fo> wrote:
>> R-help,
>>
>> I seem not to get an object saved neither with ".RData" extension nor
>> output via dput.
>>
>> Whenever I try to import the above object in another worspace I just get nothing.
>>
>>> geoFeatures <- load("geoFeatures.RData")
>>> geoFeatures
>> [1] "geoFeatures"
>>
>> The "geoFeatures.RData" workspace contains an object list called "geoFeatures"
>>
>> Thanks in advance
>>
>>
>>> version
>>               _
>> platform       i386-pc-mingw32
>> arch           i386
>> os             mingw32
>> system         i386, mingw32
>> status
>> major          2
>> minor          11.1
>> year           2010
>> month          05
>> day            31
>> svn rev        52157
>> language       R
>> version.string R version 2.11.1 (2010-05-31)
>>
>>
>>
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
>
>
> --
> Joris Meys
> Statistical consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> tel : +32 9 264 59 87
> Joris.Meys at Ugent.be
> -------------------------------
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list