title: In R, how do I use apply() with data frames?
body: <p>apply() allows you to select whether rows or columns with MARGIN=1 or MARGIN=2, respectively.</p>
  
  <p>But apply only works on matrices.</p>
  
  <p>For example, I have three rows of header information and 3 columns of descriptive information.  I need to combine these into row names and row names and column names, respectively.  So I can't easily use read.table() and skip the first 3 rows, and then delete the first 3 columns to get my matrix right away.</p>
  
  <p>This doesn't work on data frames, just matrices</p>
  
  <pre><code>rownames(df)&lt;-apply(df[,1:3], MARGIN=1,FUN=function(x){paste(x,sep=".")})
  </code></pre>