Superb Jean, many thanks Ross
From: Jean V Adams <jvad...@usgs.gov> Date: Tuesday, 6 November 2012 19:20 To: Ross Ahmed <rossah...@googlemail.com> Cc: <r-help@r-project.org> Subject: Re: [R] Apply same linear model to subset of dataframe DV <- c("mpg", "drat", "gear") IV <- list(c("cyl", "disp", "hp"), c("wt", "qsec"), c("carb", "hp")) fits <- vector("list", length(DV)) for(i in seq(DV)) { fit <- lm(formula=paste(DV[i], paste(IV[[i]], collapse="+"), sep="~"), data=mtcars) plot(fit$fitted, fit$resid, main=paste("DV", DV[i], sep="=")) lapply(fit$model[, -1], function(x) plot(x, fit$resid)) fits[[i]] <- fit } [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.