Hi,

Using the example data from library(gvlma)

library(gvlma)
data(CarMileageData)
CarMileageNew <- CarMileageData[,c(5,6,3)]
 lst1 <- list()
 y <- c("NumGallons", "NumDaysBetw")
 for(i in seq_along(y)){
 lst1[[i]] <- gvlma(lm(get(y[i])~MilesLastFill,data=CarMileageNew))
 lst1}
pdf("gvlmaplot.pdf")
 lapply(lst1,plot)
dev.off()


You could also use ?lapply().


A.K.



Hi
I have a spread sheet with a column Samples (column1) and then 34 more columns 
with different concentrations of fatty acids per sample. Im trying to run the 
same function 34 times. In this case (the first of 34), I have a fatty acid 
called C14.0 (column 2). I'm a newbie with R so I spent the last 4 days looking 
for a way of doing it (without running the same function 34 times with a 
different fatty acid each time). I saw that people do similar things with loops 
but I cannot get them to work.
I have tried the script below but it does not work.

y<-c("C14.0","C15.0","C16.0")
for (i in y) {
FA.ml=lm(i~Sample,data=FA)
gvlmaFA<-gvlma(FA.ml)
gvlmaFA
}


I really appreciate if someone can give me a hand with that. I know would have 
been finished if I had typed the 34 fatty acids but I want to learn how to do 
it with loops.
Cheers 


______________________________________________
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.

Reply via email to