Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacing data in .Rdata file

Tags:

r

rdata

Is there a way I could replace the table in .Rdata file with another one? I can edit it with edit(x) command, but it would take an enormous amount of time to do this manually; besides, I haven't found a way to add rows to it.

like image 716
user984747 Avatar asked Oct 07 '11 21:10

user984747


People also ask

What is in .RData file?

RData file contains all objects in your current workspace.

How do I save a new dataset in R?

To save data as an RData object, use the save function. To save data as a RDS object, use the saveRDS function. In each case, the first argument should be the name of the R object you wish to save. You should then include a file argument that has the file name or file path you want to save the data set to.

How do I read a .RData file?

The easiest way to load the data into R is to double-click on the particular file yourfile. RData after you download it to your computer. This will open in RStudio only if you have associated the . RData files with RStudio.


1 Answers

I think you need to read a few 'intro to R' guides.

A .Rdata file is generally a saved session, and can have any number of 'things' saved in it, scalars, vectors, data.frames, lists, functions etc etc. I assume you have a data file that has been read into R into a data.frame and that is saved within a .Rdata file. You can load the .Rdata file with load("....Rdata") then you can 'replace' your table (a data frame), by loading another one over top, if that's what you want to do, so assuming it's called dat, dat <- read.csv("new_data.csv", ...), and then save the session again, save.image("....Rdata"). I've assumed a lot of things there though...

like image 88
nzcoops Avatar answered Sep 19 '22 02:09

nzcoops