title: How to subset a Data frame column wise using column names?
body: <p>I have created a <strong>data frame</strong> named <strong>z</strong>.</p>
  
  <pre><code>  a = c(1,1,1);
    b = c(2,2,2);
    c = c(3,3,3);
    d = c(4,4,4);
    z = data.frame(a,b,c,d);
  </code></pre>
  
  <p>I want to <strong>remove column c and d from data frame z</strong>.</p>
  
  <p>I tried this code</p>
  
  <pre><code>p = subset(z , colnames(z) == c('a' , 'b'))
  </code></pre>
  
  <p>But i am getting this result</p>
  
  <pre><code>a   b   c   d
  1   2   3   4   
  1   2   3   4 
  </code></pre>
  
  <p>What changes should i make in this command to remove column <strong>c</strong> and <strong>d</strong> from <strong>z</strong>.</p>