title: unused arguments and invalid subscript type list error in R
body: <p>i am struggling with an assignment and i would like your input.
  <em>note: this is a homework but when i tried to add the tag it said not to add it..</em>
  i don't want the resulting code, just suggestions on how to get this working :)</p>
  
  <p>so, i have a t.test function as such:</p>
  
  <pre><code>    my.t.test &lt;- function(x,s1,s2){
          x1 &lt;- x[s1]
          x2 &lt;- x[s2]
          x1 &lt;- as.numeric(x1)
          x2 &lt;- as.numeric(x2)
          t.out &lt;- t.test(x1,x2,alternative="two.sided",var.equal=T)
  out &lt;- as.numeric(t.out$p.value)
          return(out)
      }
  </code></pre>
  
  <p>a matrix 30cols x 12k rows called <code>data</code> and an annotation file containing col names and data on the colums named <code>dataAnn</code></p>
  
  <p><code>dataAnn</code> first column contains a list of M (male) or F (female) corresponding to the samples (or cols) in <code>data</code> (that follow the same order as in <code>dataAnn</code>), i have to run a t.test comparing the two samples and get the p values out</p>
  
  <p>when i call </p>
  
  <pre><code>raw.pValue &lt;- apply(data,1,my.t.test,s1=dataAnn[,1]=="M",s2=dataAnn[,1]=="F")
  </code></pre>
  
  <p>i get the error </p>
  
  <pre><code>Error in t.test(x1, x2, alternative = "two.sided", var.equal = T) : 
    unused argument(s) (alternative = "two.sided", var.equal = T)
  </code></pre>
  
  <p>i even tried to use </p>
  
  <pre><code>raw.pValue &lt;- apply(data,1,my.t.test,s1=unlist(data[,1:18]),s2=unlist(data[,19:30]))
  </code></pre>
  
  <p>to divide the cols i want to compare but in this case i get the error</p>
  
  <pre><code>Error in x[s1] : invalid subscript type 'list'
  </code></pre>
  
  <p>i have been looking online, i understand that the second error is caused by an indices being a list...but this didn't really clarify it for me...
  any input would be appreciated!!</p>