Re: [R] Problem passing a statistical model as an argument

2009-08-20 Thread Frank E Harrell Jr
Gabor Grothendieck wrote: Try: w <- function(formula, ...) do.call("lm", list(formula, ...)) Thanks very much Gabor. That seems to do the trick. Thanks also Rolf and Chuck. Chuck I had tried your approach earlier but ran into a problem. Frank On Thu, Aug 20, 2009 at 7:01 PM, Frank E

Re: [R] Problem passing a statistical model as an argument

2009-08-20 Thread Charles C. Berry
On Thu, 20 Aug 2009, Frank E Harrell Jr wrote: Dear Colleagues: I would like to write a front end for a modeling function, but run into trouble when passing a weights argument. You might want to look at the code at the beginning of lm for some ideas. Something like: w <- function(formula,

Re: [R] Problem passing a statistical model as an argument

2009-08-20 Thread Gabor Grothendieck
Try: w <- function(formula, ...) do.call("lm", list(formula, ...)) On Thu, Aug 20, 2009 at 7:01 PM, Frank E Harrell Jr wrote: > Dear Colleagues: > > I would like to write a front end for a modeling function, but run into > trouble when passing a weights argument. > > y <- 1:5 > x <- c(1,3,2,5,4)

[R] Problem passing a statistical model as an argument

2009-08-20 Thread Frank E Harrell Jr
Dear Colleagues: I would like to write a front end for a modeling function, but run into trouble when passing a weights argument. y <- 1:5 x <- c(1,3,2,5,4) w <- function(formula, ...) lm(formula, ...) lm(y ~ x, weights=c(1,1,1,2,2)) w(y ~ x) w(y ~ x, weights=c(1,1,1,2,2)) Error in eval(expr