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

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

Multivariable analysis and correlation of iconography

stepAIC from package MASS with AICc