Save environment within a function

save.image(file= " xxx.Rdata") save the content of memory to be reused, but it does not work within a function. There, you can use:

save(list = ls(all.names = TRUE), file = "total.Rdata", envir = environment())


For example:


essai <- function(x) {
  blabla <- c("ldklklkdlkd")
  save(list = ls(all.names = TRUE), file = "total.Rdata", envir = environment())
}

load("total.Rdata")

Commentaires