5

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.

Elzo Valugi
  • 27,240
  • 15
  • 95
  • 114
user984747
  • 51
  • 1
  • 2
  • If the data is "visible" in an R session which it would be if you can use `edit(x)`, then adding a row can be done with rbind (which has a data.frame method). See ?rbind . And @nzcoops' comment about you needing to read more introductory material seems on point and you might consider searching SO: http://stackoverflow.com/questions/6516116/appending-data-in-r http://stackoverflow.com/questions/3040352/merge-two-data-frames-together-that-have-the-same-variable-names-and-data-types http://stackoverflow.com/questions/3665885/adding-a-list-of-vectors-to-a-data-frame-in-r – IRTFM Oct 08 '11 at 09:39

1 Answers1

9

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

nzcoops
  • 9,132
  • 8
  • 41
  • 52
  • No worries. You can select this as the chosen answer by clicking the tick under the voting buttons if you like. Don't have to, it's your choice. Glad you got there. – nzcoops Oct 10 '11 at 02:00