Re: [R] Unable to load an object

From: Henrik Bengtsson <hb_at_stat.berkeley.edu>
Date: Fri, 11 Jun 2010 16:34:02 +0200

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.
>



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. Received on Fri 11 Jun 2010 - 14:36:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Jun 2010 - 15:00:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive