Re: [R] lm weights argument within function

2014-08-01 Thread William Dunlap
One way to accomplish this is to assign a new environment to the formula, an environment which inherits from the formula's original environment but one that you can add things to without affecting the original environment. Also, since you do this in a function only the copy of the formula in the f

[R] lm weights argument within function

2014-08-01 Thread Daniel Caro
Hi all, I need to loop over "lm" within a function using "weights". For example: mydata = data.frame(y=rnorm(100, 500, 100), x= rnorm(100), group=rep(c(0,1), 50), myweight=1/runif(100)) reg.by.wt <- function(formula, wt, by, data) { if(missing(by)) { summary(lm(formula=formula, data=data,