Getting column names for max value in each row
<p>I have a dataset which looks like the following-</p>

<pre><code>cluster1      cluster2      cluster3
0.0795604798  0.0934697636 -0.396044650
0.0086171605 -0.1467907623 -0.396044650
1.8838058726 -0.1507548515 -0.396044650
</code></pre>

<p>I want to get the cluster number for each row, which will be the maximum value. It should look something like this-</p>

<pre><code>value           cluster
0.0934697636    cluster2
0.0086171605    cluster1
1.8838058726    cluster1
</code></pre>

<p>I'm doing it in R. If I use the following command, I get the maximum observation from each row-</p>

<pre><code>k=colnames(apply(cscore,1,max))
</code></pre>

<p>But I'm not sure how to get the cluster name as well.</p>