Skip to content

R save RData

Xu Gang edited this page Dec 10, 2021 · 2 revisions
# Save the city object
saveRDS(city, "city.rds")

# ...

# Load the city object as city
city <- readRDS("city.rds")

# Or with a different name
city2 <- readRDS("city.rds")

# save multiple variable into one rdata
var1 = "foo"
var2 = 2
var3 = list(a="abc", z="xyz")
ls()
save(list=c("var1", "var2", "var3"), file="myvariables.RData")
rm(list=ls())
ls()

load("myvariables.RData")
ls()

Clone this wiki locally