2

Writing a fresh .Rda file to save a data.frame is easy:

df <- data.frame(a=c(1,2,3,4), b=c(5,6,7,8))
save(df,file="data.Rda")

But is it possible to write more data afterwards, there is no append=TRUE option using save.

Similarly, writing new lines to a text file is easy using:

write.table(df, file = 'data.txt', append=T)

However for large data.frames, the resulting file is much larger.

JohnBee
  • 1,720
  • 1
  • 15
  • 19
  • Adding append to save sounds interesting, but would it not be easier to use `load()` and than add something to it with `tibble::add_row()` or whatever other method? – RobertMyles Jun 22 '17 at 12:27
  • 5
    You can't (in general) append to Rdata file without loading it first, because of how the file format works. See https://stackoverflow.com/questions/33741620/how-to-append-a-vector-as-a-row-in-a-saved-rdata-file-with-r – Richard Jun 22 '17 at 12:28

1 Answers1

2

If you use Microsoft R, you might want to check RevoScaler package, rxImport function in particular. It allows you to store compressed data.frame in file, it also allows you to append new lines to existing file without loading it into environment.

Hope this helps. Link on function documentation below.

https://learn.microsoft.com/en-us/machine-learning-server/r-reference/revoscaler/rximport

Martin Fridrich
  • 314
  • 2
  • 8