On Mon, 3 Jul 2006, John Sorkin wrote:
> R 2.2 on windows XP
> I have a dataset with multiple columns. Some of the columns represent
> independent variables, some represent dependent variables. I would like
> to run the same analyses on a fixed set of independent variables,
> changing only the dependent variable, e.g.
> y1-y2=x1+x2+x3
> y3-y4=x1+x2+x3
> y5-y6=x1+x2+x3, etc.

Other people have mentioned my defmacro() function in R-news, however when 
I have to do this sort of thing I usually use substitute or bquote

For example

for(i in 1+(1:5)*2){
   A<-as.name(paste("y",i,sep=""))
   B<-as.name(paste("y",i+1,sep="")
   eval(bquote(lm(I(.(A)-.(B))~x1+x2+x3,data=dat)))
}


        -thomas

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to