Managing data with R
One of the challenges faced when working with massive datasets involves gathering, preparing, and otherwise managing data from a variety of sources. This task is facilitated by R's tools for loading data from many common formats.
Saving and loading R data structures
When you have spent a lot of time getting a particular data frame into the format that you want, you shouldn't need to recreate your work each time you restart your R session. To save a particular data structure to a file that can be reloaded later or transferred to another system, you can use the save()
function. The save()
function writes R data structures to the location specified by the file
parameter. R data files have the file extension .RData
.
If we had three objects named x
, y
, and z
, we could save them to a file mydata.RData
using the following command:
> save(x, y, z, file = "mydata.RData")
Regardless of whether x
, y
, and z
are vectors, factors, lists, or data frames, they will be saved to the file...