title: Sort a subset of columns for each row
body: <p>I want to sort my.data[4:10] in descending order by row.  Some clues here, but I could not parse it sufficiently: <a href="https://stackoverflow.com/questions/24047423/sort-second-to-fifth-column-for-each-row-in-r">Sort second to fifth column for each row in R</a>.</p>
  
  <p>I also tried things like:</p>
  
  <pre><code>sort(my.data, decreasing = TRUE, partial = c([4:10]))
  </code></pre>
  
  <p>which didn't work, but I think the former is more in line with what I need.  I read through ?cbind, ?apply, and ?sort help, but the examples are just to cryptic for me.</p>
  
  <p>Here's my sample dataset:</p>
  
  <pre><code>habitat&lt;-c('Marsh','Prairie','Savanna','Swamp','Woodland')
  NumSites&lt;-c(3,3,4,1,4)
  NumSamples&lt;-c(6,5,8,2,8)
  Sp1&lt;-c(NA,2,NA,2,1)
  Sp2&lt;-c(NA,2,1,NA,1)
  Sp3&lt;-c(NA,NA,NA,NA,1)
  Sp4&lt;-c(3,NA,NA,NA,NA)
  Sp5&lt;-c(NA,NA,3,NA,NA)
  Sp6&lt;-c(1,NA,67,NA,2)
  Sp7&lt;-c(NA,2,3,NA,1)
  
  my.data&lt;-data.frame(habitat,NumSites,NumSamples,Sp1,Sp2,Sp3,Sp4,Sp5,Sp6,Sp7)
  
  # I suspect a varient of this must work:
  # cbind(df[,1], t(apply(df[,-1], 1, sort)))
  </code></pre>
  
  <p>desired result should look like:</p>
  
  <pre><code>habitat  NumSites NumSamples Sp1 Sp2 Sp3 Sp4 Sp5 Sp6 Sp7
  Marsh    3        6          3   1   NA  NA  NA  NA  NA
  Prairie  3        5          2   2   2   NA  NA  NA  NA
  Savanna  4        8          67  3   3   1   NA  NA  NA
  Swamp    1        2          2   NA  NA  NA  NA  NA  NA
  Woodland 4        8          2   1   1   1   1   NA  NA
  </code></pre>
  
  <p>I feel like the cbind approach is close...</p>
  
  <p>Also, actual data has many and varied number of columns and column names, so I want to use range [4:10] instead of names of columns.</p>