Dump/Source

The 141 lab datasets (see for example Anscombe's data) were created with the R dump() function. dump() creates a file in a format that can be read with the source() function or pasted in with the copy/paste edit functions of the windowing system.

Note: on the Macintosh systems in ETC211 you may need to change the working directory before using dump(). Pull down the tools menu, select "change working directory", and select "Desktop". Don't forget to hit the "continue" button to apply the change.

Example:

     x <- rnorm(10)
     y <- rnorm(10)
     xy <- data.frame(x,y)
     xy  # look at the dataset
     
     dump("xy",file="xy.R")
     rm(xy)  # remove the dataset
   
     source(file="xy.R")
     xy  # look at the dataset


In my own work, I use the file extension ".R" to denote files generated with the dump() function, and ".dat" to denote raw data files.