Rev 41270 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{load}\alias{load}\title{Reload Saved Datasets}\description{Reload datasets written with the function \code{save}.}\usage{load(file, envir = parent.frame())}\arguments{\item{file}{a (readable binary) connection or a character stringgiving the name of the file to load.}\item{envir}{the environment where the data should be loaded.}}\details{\code{load} can load \R objects saved in the current or any earlierformat. It can read a compressed file (see \code{\link{save}})directly from a file or from a suitable connection (including a callto \code{\link{url}}).Only \R objects saved in the current format (used since \R 1.4.0)can be read from a connection. If no input is available on aconnection a warning will be given, but any input not in the currentformat will result in a error.Loading from an earlier version will give a warning about the\sQuote{magic number}: magic numbers \code{1971:1977} are from \R <0.99.0, and \code{R[ADX]1} from \R 0.99.0 to \R 1.3.1.}\value{A character vector of the names of objects created, invisibly.}\section{Warning}{Saved \R objects are binary files, even those saved with\code{ascii = TRUE}, so ensure that they are transferred withoutconversion of end of line markers. \code{load} tries to detect thiscase and give an informative error message.}\note{Prior to \R 2.4.0 an object saved as a \code{\link{pairlist}} wascoerced to a \code{list}, silently (and undocumented).}\seealso{\code{\link{save}}, \code{\link{download.file}}.}\examples{## save all dataxx <- pi # to ensure there is some datasave(list = ls(all=TRUE), file= "all.Rdata")rm(xx)## restore the saved values to the current environmentlocal({load("all.Rdata")ls()})## restore the saved values to the user's workspaceload("all.Rdata", .GlobalEnv)unlink("all.Rdata")\dontrun{con <- url("http://some.where.net/R/data/example.rda")## print the value to see what objects were created.print(load(con))close(con) # url() always opens the connection}}\keyword{file}