load
Reload Saved Datasets
Description
Reloads objects (saved with the save function)
from a dataset file or connection.
Usage
load(file, envir = parent.frame(), verbose = FALSE)
Arguments
file |
a character string specifying the dataset's filename or connection object.
|
envir |
an environment where the loaded objects are assigned.
|
verbose |
a logical value. This argument is currently ignored.
|
Details
This function supports the RData and (TIBCO Enterprise Runtime for R-specific) SData formats.
The engine can load most files saved from R, with a few exceptions.
If the file contains complicated model objects such as a glm
model, the load might fail or the model might be corrupt. (Such models
contain references to implementation-specific functions that are
different between TIBCO Enterprise Runtime for R and R. Some non-trivial environments might
also cause problems.)
If the file was not created with the save function, or if the
file contains unsupported features, an error is displayed.
Value
returns a character vector with the names of the loaded objects.
Side Effects
The loaded objects are assigned to the envir environment.
See Also
Examples
# Example to load from a file.
rm(list = ls())
x <- runif(10)
y <- rnorm(10)
z <- lm(y~x)
a <- matrix(1:12, nrow = 3)
save(list = ls(), file = "test.data", compress = "bzip2")
rm(list = ls())
load("test.data")
ls()
rm(list = ls())
my_env <- new.env()
load("test.data", my_env) # load to another environment
ls(envir = my_env)
unlink("test.data")
# Example to load from a connection
rm(list = ls())
x <- runif(10)
y <- rnorm(10)
z <- lm(y~x)
a <- matrix(1:12, nrow = 3)
save(list = ls(), file = "test.data")
rm(list = ls())
con <- file("test.data", "rb")
load(con)
ls()
close(con)
unlink("test.data")