[R] problem with save function

Henrik Bengtsson hb at stat.berkeley.edu
Tue Aug 19 02:09:37 CEST 2008


...and see saveObject() and loadObject() in R.utils, which might do
what you expected, e.g.

> x <- stats::runif(20)
> y <- list(a=1, b=TRUE, c="oops")
> saveObject(list(foo=x,bar=y), "xy.Rdata")
> xy <- loadObject("xy.Rdata")
> str(xy)
List of 2
 $ foo: num [1:20] 0.1154 0.6534 0.0876 0.5977 0.6841 ...
 $ bar:List of 3
  ..$ a: num 1
  ..$ b: logi TRUE
  ..$ c: chr "oops"

/Henrik

On Mon, Aug 18, 2008 at 5:02 PM, Rolf Turner <r.turner at auckland.ac.nz> wrote:
>
> Read the help for load(); note the ``Value'' section.
>
>        cheers,
>
>                Rolf Turner
>
> On 19/08/2008, at 11:51 AM, Juan Manuel Barreneche wrote:
>
>> Hello list! i write because i'm having a strange problem with the "save"
>> function, here an example:
>>
>>> x <- stats::runif(20)
>>> y <- list(a = 1, b = TRUE, c = "oops")
>>> save(x, y, file = "xy.Rdata")
>>> xy <- load("xy.Rdata")
>>> xy
>>
>> [1] "x" "y"
>>
>> why does this happens, when:
>>>
>>> x
>>
>>  [1] 0.96586833 0.60340508 0.23465887 0.01415043 0.57691296 0.13302310
>>  [7] 0.01874176 0.59097297 0.41550847 0.76732502 0.01802066 0.11413294
>> [13] 0.93441672 0.70013043 0.10277732 0.43738180 0.96744498 0.45388743
>> [19] 0.84598918 0.96785481
>>>
>>> y
>>
>> $a
>> [1] 1
>>
>> $b
>> [1] TRUE
>>
>> $c
>> [1] "oops"
>>
>> I run R in openSUSE 10.2, in KDE with Konsole, my version and OS
>> information
>> is:
>>>
>>> R.Version()
>>
>> $platform
>> [1] "i686-pc-linux-gnu"
>> $arch
>> [1] "i686"
>> $os
>> [1] "linux-gnu"
>> $system
>> [1] "i686, linux-gnu"
>> $status
>> [1] ""
>> $major
>> [1] "2"
>> $minor
>> [1] "7.0"
>> $year
>> [1] "2008"
>> $month
>> [1] "04"
>> $day
>> [1] "22"
>> $`svn rev`
>> [1] "45424"
>> $language
>> [1] "R"
>> $version.string
>> [1] "R version 2.7.0 (2008-04-22)"
>>
>> many thanks in advance,
>>
>> Juan
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>
>
> ######################################################################
> Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
>
> ______________________________________________
> 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