[R] Save/Load function()-result to file in a loop

Johannes Radinger JRadinger at gmx.at
Thu Mar 8 13:57:17 CET 2012


Hi,

I am looking for a way to save the result of a function, e.g the lm()-function to a file and reload it afterwards again. I'd like to do that in order to minimize the used memory when running the function in a loop. The actual function I want to store is the evaluate() from the dismo package.
I tried it with save() and load() but I am not sure if that is the way I should do it as I don't get the result I desire...

ls <- list("A","B","C")
for(i in ls){
	x <- lm(c(1,2,3)~c(2,5,6))
	save(x, file = paste("/path/to/file_",i,sep=""))
}

A <- load("/path/to/file_A")

/Johannes
-- 

Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a



More information about the R-help mailing list