Alex Rivera | Logout

How to save a data frame in R?

Asked 2011-12-01T17:37:54.687
172

I made a data frame in R that is not very big, but it takes quite some time to build. I would like to save it as a file, which I can then again open in R. How do I achieve this?

Edit
Report

1 Answer

222

There are several ways. One way is to use save() to save the exact object. e.g. for data frame foo:

save(foo,file="data.Rda")

Then load it with:

load("data.Rda")

You could also use write.table() or something like that to save the table in plain text, or dput() to obtain R code to reproduce the table.

answered 2011-12-01T17:41:33.653

Your Answer