title: R script, count max values in a row of data
body: <p>I have this chunk of code in an R script, and what it does is that from a data frame (that has say 4 columns) finds and counts for each row the column with the maximal value. But when in a row there are ties (say two or maybe three max values), the code below just considers the first one (does not count the other ones). Is there in R any way to count the columns with max value even when there are multiple max values (ties?) in rows.</p>
  
  <pre><code>m_0 &lt;- read.csv(file="Tests/myResults", head=FALSE, sep=",")
  
  varb_m0 &lt;- c(m0$ V4)
  
  #create dataframe
  </code></pre>
  
  <blockquote>
    <p>myDataFrame &lt;- data.frame(mode_0=varb_m0)</p>
  </blockquote>
  
  <pre><code>#find max
  result &lt;- apply(myDataFrame,1,which.max)
  
  #factor it
  result &lt;- factor(result)
  
  #print result
  names(myDataFrame)[result]
  
  summary(result)
  </code></pre>