[R] Updata Rdata File

Joshua Wiley jwiley.psych at gmail.com
Thu Nov 18 17:31:27 CET 2010


Hi Jason,

You can add as many objects as you want to save().  For instance:
save(data1, data2, data3, data4, file = "whatever").  Once you have
loaded the data, just add whatever data you want, and then save it (or
edit your original object and resave it).  Here is another example:

> ls()
character(0)
> load("rhelp.RData")
> ls()
[1] "x"
> ## Now I could edit, 'x' (e.g., rbind() in additional rows, etc.)
> ## or I could create a new variable, 'y'
> y <- 1:10 # some new data
> ## from
> ?save
> save(x, y, file = "rhelp.RData")
> ## clear space and show it is empty
> rm(list=ls()); ls()
character(0)
> load("rhelp.RData")
> ls()
[1] "x" "y"
> ## now both 'x' and 'y' are in the RData file
> ## if I had just edited x and resaved, it would be updated

Cheers,

Josh

On Thu, Nov 18, 2010 at 7:26 AM, Jason Kwok <jaykwok at gmail.com> wrote:
> Thanks for the response Duncan.
>
> I'm sorry I wasn't clear in my question.  I need to add an additional value
> every day to the data and not update it.
>
> I know how to load and save but I dont' know how to add data.
> load(file="C:\\datafile.rdata")
> save(data,file="C:\\datafile.rdata")
>
> Thanks.
>
> Jason
>
> On Thu, Nov 18, 2010 at 6:56 AM, Duncan Murdoch <murdoch.duncan at gmail.com>wrote:
>
>> On 18/11/2010 1:49 AM, Jason Kwok wrote:
>>
>>> How do I add data to a .rdata file?  In my case, I have a time series that
>>> needs to get updated every day.
>>>
>>
>> Load it, update the variables, save them.
>>
>> Duncan Murdoch
>>
>
>        [[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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list