title: Best practice to get a dropped column in dplyr tbl_df
body: <p>I remember a comment on r-help in 2001 saying that <code>drop = TRUE</code> in <code>[.data.frame</code> was the worst design decision in R history. </p>
  
  <p><code>dplyr</code> corrects that and does not drop implicitly. When trying to convert old code to <code>dplyr</code> style, this introduces some nasty bugs when <code>d[, 1]</code> or <code>d[1]</code> is assumed a vector.</p>
  
  <p>My current workaround uses <code>unlist</code> as shown below to obtain a 1-column vector. Any better ideas?</p>
  
  <pre><code>library(dplyr)
  
  d2 = data.frame(x = 1:5, y = (1:5) ^ 2)
  str(d2[,1]) # implicit drop = TRUE
  # int [1:5] 1 2 3 4 5
  
  str(d2[,1, drop = FALSE])
  # data.frame':  5 obs. of  1 variable:
  #  $ x: int  1 2 3 4 5
  
  # With dplyr functions
  d1 = data_frame(x = 1:5, y = x ^ 2)
  str(d1[,1])
  # Classes ‘tbl_df’ and 'data.frame':    5 obs. of  1 variable:
  #  $ x: int  1 2 3 4 5
  
  str(unlist(d1[,1]))
  # This ugly construct gives the same as str(d2[,1])
  str(d1[,1][[1]])
  </code></pre>