Skip to content
Prev 4468 / 63424 Next

works in R-1.1.1 but not in R-development; why?

Ramon Diaz-Uriarte <ramon-diaz@teleline.es> writes:
Ow!... This happens because of a change that makes formulas capture
their environment of definition.

A workaround is to explicitly set the environment of the formula to
the current environment, like this:

lapply(split(datai,datai$counter),
       function(datos,formula) {
	  environment(formula)<-environment()
	  lm(formula = formula, data = datos,
                                   weights = datos$x2)
       },
       formula = formula) 

but I bet Luke wants to comment on this...