How to use save.image and load method In R Language

The save.image method in R is used to save the current workspace files. It is an extended version of the save method in R which is used to create a list of all the declared data objects and save them into the workspace. These files can then later be read into the corresponding saved data objects using the load() method. 

Syntax:

save.image(file = “.RData”)

Arguments : 

file – name of the file where the R object is saved to or read from.

Example: Saving R data workspace files

R




# creating data objects
obj1 <- c(1:5)         
obj2 <- FALSE                      
obj3 <- "w3wiki!!"  
 
# saving all data to the path
save.image("saveworkspace.RData")


 
These files can be loaded into the workspace using load() function.

Syntax: 

Load(path)

Example: Loading R data workspace files 

R




# loading the workspace
load("saveworkspace.RData")


 
Output: 

Save and Load RData Workspace Files in R

In this article, we will discuss how to save and load R data workspace files in R programming language.

Similar Reads

Method 1: Using save.image and load method

The save.image method in R is used to save the current workspace files. It is an extended version of the save method in R which is used to create a list of all the declared data objects and save them into the workspace. These files can then later be read into the corresponding saved data objects using the load() method....

Method 2: Using saveRDS and readRDS method

...

Method 3: Using the save and load method

...

Contact Us