Hi Arun,
Your script works but it does not do what I was after. To be a bit more
specific,  this the table FA in which Im working on ( but the original one
has 34 fatty acids instead of 3: C14.0, C15.0, and C15.1).

SampleC14:0C15:0C15:1
L1 Control0.4565091920.4695626870.774909216
L1 Control0.5139896840.5279580260.732083085
L1 Control0.5558944960.5023896990.706407924
BBM Control0.4183927810.3851193291.318261983
BBM Control0.4058262920.3685645141.114889958
BBM Control0.3986339680.3918514931.238411437
L1 Ash0.5045280780.4791255770.793236101
L1 Ash0.5486679970.5175339220.632962545
L1 Ash0.4992376450.4906198580.74858627
BBM Ash0.3805822440.3800515350.996870831
BBM Ash0.3956179430.3844982160.963780759
BBM Ash0.3890271150.3708154740.923329859

I just want to run the following script but with C15.0, C15.1 and the other
32 so I can quickly scroll up and down to see who does not meet the
assumptions.

FA.ml=lm(C14.0~Sample,data=FA)
gvlmaFA<-gvlma(FA.ml)
gvlmaFA

This is the result when I run the script

Call:
lm(formula = C14.0 ~ Sample, data = FA)

Coefficients:
      (Intercept)  SampleBBM Control       SampleL1 Ash   SampleL1 Control
          0.38841            0.01921            0.12907            0.12039


ASSESSMENT OF THE LINEAR MODEL ASSUMPTIONS
USING THE GLOBAL TEST ON 4 DEGREES-OF-FREEDOM:
Level of Significance =  0.05

Call:
 gvlma(x = FA.ml) 

                       Value p-value                   Decision
Global Stat        4.757e+00 0.31312    Assumptions acceptable.
Skewness           1.944e-02 0.88911    Assumptions acceptable.
Kurtosis           1.462e-01 0.70219    Assumptions acceptable.
Link Function      3.682e-16 1.00000    Assumptions acceptable.
Heteroscedasticity 4.592e+00 0.03213 Assumptions NOT satisfied!

I really appreciate if you can help me with this issue. This would be really
useful for me since I have large tables of data.
Cheers


From:  "arun kirshna [via R]" <ml-node+s789695n4689190...@n4.nabble.com>
Date:  Mon, 21 Apr 2014 06:29:10 -0700 (PDT)
To:  Carlos <carlosalvarez...@hotmail.com>
Subject:  Re: Loops (run the same function per different columns)

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] </user/SendEmail.jtp?type=node&node=4689190&i=0>  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-colu
mns-tp4689171p4689190.html
To unsubscribe from Loops (run the same function per different columns),
click here 
<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by
_code&node=4689171&code=Y2FybG9zYWx2YXJlenJvYUBob3RtYWlsLmNvbXw0Njg5MTcxfDIx
MjE0NTUw> .
NAML 
<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&i
d=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamesp
ace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNa
mespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%
21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>






--
View this message in context: 
http://r.789695.n4.nabble.com/Loops-run-the-same-function-per-different-columns-tp4689171p4689350.html
Sent from the R help mailing list archive at Nabble.com.
        [[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.

Reply via email to