title: Identifying duplicate columns in a dataframe
body: <p>I'm an R newbie and am attempting to remove duplicate columns from a largish dataframe (50K rows, 215 columns).  The frame has a mix of discrete continuous and categorical variables.</p>
  
  <p>My approach has been to generate a table for each column in the frame into a list, then  use the <code>duplicated()</code> function to find rows in the list that are duplicates, as follows:</p>
  
  <pre><code>age=18:29
  height=c(76.1,77,78.1,78.2,78.8,79.7,79.9,81.1,81.2,81.8,82.8,83.5)
  gender=c("M","F","M","M","F","F","M","M","F","M","F","M")
  testframe = data.frame(age=age,height=height,height2=height,gender=gender,gender2=gender)
  
  tables=apply(testframe,2,table)
  dups=which(duplicated(tables))
  testframe &lt;- subset(testframe, select = -c(dups))
  </code></pre>
  
  <p>This isn't very efficient, especially for large continuous variables.  However, I've gone down this route because I've been unable to get the same result using summary (note, the following assumes an original <code>testframe</code> containing duplicates):</p>
  
  <pre><code>summaries=apply(testframe,2,summary)
  dups=which(duplicated(summaries))
  testframe &lt;- subset(testframe, select = -c(dups))
  </code></pre>
  
  <p>If you run that code you'll see it only removes the first duplicate found. I presume this is because I am doing something wrong.  Can anyone point out where I am going wrong or, even better, point me in the direction of a better way to remove duplicate columns from a dataframe?</p>