title: How to drop columns by name in a data frame
body: <p>I have a large data set and I would like to read specific columns or drop all the others.</p>
  
  <pre><code>data &lt;- read.dta("file.dta")
  </code></pre>
  
  <p>I select the columns that I'm not interested in:</p>
  
  <pre><code>var.out &lt;- names(data)[!names(data) %in% c("iden", "name", "x_serv", "m_serv")]
  </code></pre>
  
  <p>and than I'd like to do something like:</p>
  
  <pre><code>for(i in 1:length(var.out)) {
     paste("data$", var.out[i], sep="") &lt;- NULL
  }
  </code></pre>
  
  <p>to drop all the unwanted columns. Is this the optimal solution?</p>