[R] Passing arguments to glm()

2006-06-30 Thread Christian Bieli
Hi there I want to pass arguments (i.e. the response variable and the subset argument) in a self-made function to glm. Here is one way I can do this: f.myglm - function(y,subfact,subval) { glm(d.mydata[,y]~d.mydata[,'x1'],family=binomial,subset=d.mydata[,subfact]==subval) } str(d.mydata)

Re: [R] Passing arguments to glm()

2006-06-30 Thread Jacques VESLOT
f.myglm - function(y=y, subset=x2 == 'yes', data=d.d.mydata) eval(parse(text=glm(, deparse(substitute(y)), ~ x1, family=binomial, data=, deparse(substitute(data)), , subset =, subset, ))) f.myglm() --- Jacques VESLOT CNRS

Re: [R] Passing arguments to glm()

2006-06-30 Thread Jacques VESLOT
i forgot a paste(): f.myglm - function(y=y, subset=x2 == 'yes', data=d.d.mydata) eval(parse(text=paste(glm(, deparse(substitute(y)), ~ x1, family=binomial, data=, deparse(substitute(data)), , subset =, subset, ), sep=))) --- Jacques

Re: [R] Passing arguments to glm()

2006-06-30 Thread Gabor Grothendieck
This is the same as glm except that - formula may be of class character in which case its regarded as the name of the response variable and the formula defaults to resp ~ Species for that response - the data frame defaults to iris - modify as appropriate for your case myglm - function