Previous: Verifying You Loaded The Up: Data Sets Next: Variables


Saving Data

Use save() to write data or any object to a file in your working directory. For example,

> save(mydata, file = "mydata.RData")     # Saves `mydata' to `mydata.RData'
                                          #  in your working directory.  
> save.image()                            # Saves your entire workspace to
                                          #  the default `.RData' file.
R will also prompt you to save your workspace when you use the q() command to quit. When you start R again, it will load the previously saved workspace. Restarting R will not, however, load previously used packages. You must remember to load Zelig at the beginning of every R session.

Alternatively, you can recall individually saved objects from .RData files using the load() command. For example,

> load("mydata.RData")
loads the objects saved in the mydata.RData file. You may save a data frame, a data frame and associated functions, or other R objects to file.



Gary King 2011-11-29