Thank you Arun for your quick answer.
Ill try it and ill let you know.
Cheers



On 21/04/2014, at 11:30 PM, "arun kirshna [via R]" 
<[email protected]> wrote:

> 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 
> 
> 
> ______________________________________________ 
> [hidden email] 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. 
> 
> 
> If you reply to this email, your message will be added to the discussion 
> below:
> http://r.789695.n4.nabble.com/Loops-run-the-same-function-per-different-columns-tp4689171p4689190.html
> To unsubscribe from Loops (run the same function per different columns), 
> click here.
> NAML




--
View this message in context: 
http://r.789695.n4.nabble.com/Loops-run-the-same-function-per-different-columns-tp4689171p4689228.html
Sent from the R help mailing list archive at Nabble.com.
        [[alternative HTML version deleted]]

______________________________________________
[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
and provide commented, minimal, self-contained, reproducible code.

Reply via email to