[R] reaccessing array at a later date - trying to write it to file

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Nov 23 16:17:15 CET 2006


On Thu, 23 Nov 2006, Jenny Barnes wrote:

> Thank you for your response Professor Ripley,
>
> Having tried again your suggestion of load() worked (well - it finished, which I
> assume it meant it worked). However not I am confused as to how I can check it
> has worked.
> I typed
>> data.out$data
> which called up the data from the file - but I'm not sure if this is data from
> the file I have just restored as in my "previously saved workspace restored"
> data.out is still there so if I typed data.out$data I wouldn't know if it was
> coming from the newly loaded file or from previously. Is there an alternative
> way to check it has loaded properly? Also, is it normal that if I type
>> data.out.RData
> it says
> Error: object "data.out.RData" not found

Yes.

I think it worked, but try load() in a new session to be sure.

>
> Here are my details:
>
> platform       sparc-sun-solaris2.10
> arch           sparc
> os             solaris2.10
> system         sparc, solaris2.10
> status
> major          2
> minor          3.1
> year           2006
> month          06
> day            01
> svn rev        38247
> language       R
> version.string Version 2.3.1 (2006-06-01)
>
> My computer shouldn't have a problem with dealing with this data.
>
>> On Thu, 23 Nov 2006, Jenny Barnes wrote:
>>
>>> Dear R-help community
>>>
>>> I am trying to write an R object (data.out) to a file in order to re-access
> it
>>> later and not have to re-load up the array with data every time. Here is the
>>> form of data.out
>>>
>>>> data.out <- list(lats=seq(88.542, -88.542, length=94),
>>> 		  lons=seq(0, 360-1.875, length=192),
>>> 		  date=vector(length=nyr*12),
>>> 		  data=array(NA, c(nyr*12, 94*192))
>>> )
>>>
>>> I tried
>>>> save(data.out, file="/home/jenny/data/data.out.RData", ascii=TRUE) and
>>> combination of ways to re-access it but I couldn't reaccess it and therefore
> use
>>> the data within.
>>
>> What stopped you re-accessing it?  I would use
>>
>> save(data.out, file="/home/jenny/data/data.out.RData")
>> ....
>> load("/home/jenny/data/data.out.RData")
>>
>> If that does not work, we need to see the transcript to (perhaps)
>> understand why (and all the usual details about your environment: it is
>> possible to save really large objects that you cannot restore on a
>> 32-bit machine).
>>
>> --
>> Brian D. Ripley,                  ripley at stats.ox.ac.uk
>> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>> University of Oxford,             Tel:  +44 1865 272861 (self)
>> 1 South Parks Road,                     +44 1865 272866 (PA)
>> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Jennifer Barnes
> PhD student - long range drought prediction
> Climate Extremes
> Department of Space and Climate Physics
> University College London
> Holmbury St Mary, Dorking
> Surrey
> RH5 6NT
> 01483 204149
> 07916 139187
> Web: http://climate.mssl.ucl.ac.uk
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list