title: R: Subset: Using whole dataframe except one column
body: <p>I'd like to exclude one single column from a operation on a dataframe. Of course I could just replicate the dataframe without the column that I want to exclude, but this seems to be a workaround. There must be an easier way to subset I think.</p>
  
  <p>So this example code should show what I am up to. </p>
  
  <pre><code>df&lt;-data.frame(a=c(1:5),b=c(6:10),c=c(11:15))
  # First subset: operate on a single column
  mean(df[,1])
  [1] 3
  # Second subset: with a set of choosen columns
  colMeans(df[,c(1,3)])
  a  c 
  3 13 
  # third subset: exclude column b from the operation (expected Output should be like the second subset)
  colMeans(df[,!=2])
  Error: unexpected '!=' in "colMeans(df[,!="
  </code></pre>
  
  <p>Any help would be very appreciated. </p>