Reading and Saving data file in R session

Suppose you want to save an individual object in R and read it later.

Saving data file in R session
saveRDS(mydata, "logistic.rds")
Reading stored data from R session
mydata = readRDS("logistic.rds")
Note : You can define any name other than mydata.

Another way : Saving data file in R session
save (mydata,file="E:\\logistic.rdata")
Loading stored data from R session
load("E:\\logistic.rdata", ex <- new.env())
ls(ex)
Saving multiple objects in R session
save(mydata, data2, file="1.RData")
Saving everything in R session
save.image(file="1.RData")
Related Posts
About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he has worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and Human Resource.

2 Responses to "Reading and Saving data file in R session"
  1. How does Is(ex) work? And how are you ensuring that the dataset us being loaded in new environment?

    ReplyDelete

Next → ← Prev
Love this Post? Spread the Word!
Share