title: Anova, for loop to apply function
body: <pre><code>&gt;str(set)
  'data.frame':   1000 obs. of  6 variables:
  $ ID       : Factor ..
  $ a : Factor ..
  $ b: Factor ..
  $ c: Factor ..
  $ dat    : num  ..
  $ contrasts : Ord.factor ..
  
  
  &gt;X
  [1] "a"  "b" "c" 
  
  
  for (i in 1 :length(X) ){
    my=X[i]
    f=as.formula(paste("dat~contrasts*", paste(my,"Error(ID/(contrasts))",sep="+")))
    sum = summary( aov (f, data =set))
  }
  </code></pre>
  
  <p>X can be very huge, so  was thinking about an apply function instead of for-loop.Is it possible in this case?? </p>
  
  <p>I tried this:</p>
  
  <pre><code>apply(
    as.matrix(X), 1, function(i){
      summary(aov(as.formula(paste("dat~contrasts*",
        paste(i, "Error(ID/(contrasts))", sep="+"))), data=set))
    }
  )
  </code></pre>
  
  <p>But this makes no sense. Can anyone help me?</p>