Duncan Murdoch <murdoch.dun...@gmail.com> writes: > On 07/09/2010 4:18 PM, Johann Hibschman wrote: >> Going through that code, I settled on the following function to remove >> all but the most needed components: >> >> ## Strip down a glm object, until it can only be used for prediction, >> ## but is nice and small. >> strip.glm<- function (f) { >> f.str<- list(coefficients=f$coefficients, >> family=f$family, >> terms=f$terms, >> qr=list(pivot=f$qr$pivot), >> rank=f$rank, >> na.action=f$na.action)
For posterity: including the na.action here was a mistake, an untested experiment that I accidentally copied when posting. It's relatively big, and I don't think I need it. >> attr(f.str$terms, ".Environment")<- globalenv() >> class(f.str)<- class(f) >> f.str >> } > > I think a safer modification would be to set the environment to > emptyenv(). That won't take any space, but it means if you > miscalculated and some variables in that environment really were being > used, you'll get an error instead of a wrong answer. Thanks, that's helpful. Cheers, Johann ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.