"Subramanian Karthikeyan" <[EMAIL PROTECTED]> writes: > My previous question put in a simpler way: > > How would I pass a value of a variable to a function such as > > lm(Effect1~Trt*Dose, data = x, contrasts = list(Trt = contr.sum, Dose = > contr.sum))? > > Here, 'Effect' is a column name in my data matrix, and I want "Effect1" to > be replaced by "Effect2" and so on (my other column names in the data > frame) for successive anova calculations. So I am storing the column names > as an array, and passing the array as a parameter to the lm() function.
A canonical trick is for (myname in names(myframe)){ mycall <- substitute(lm(myvar~etc.etc.....),list(myvar=as.name(myname))) myfit <- eval(mycall) print(summary(myfit)) } -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help