title: How do you clear column elements from an R data frame based off of other another columns elements in the same data frame?
body: <p>I have the following data frame </p>
  
  <pre><code>&gt;data.frame
  
  col1    col2
            A
    x       B
            C
            D
    y       E
  </code></pre>
  
  <p>I need a new data frame that looks like:</p>
  
  <pre><code>&gt;new.data.frame
  
    col1    col2
             A
     x       
             C
             D
     y       
  </code></pre>
  
  <p>I just need a method for reading from col1 and if there is ANY characters in Col1 then clear corresponding row value of col2. I was thinking about using an if statement and data.table for this but am unsure of how to relay the information for deleting col2's values based on ANY characters being present in col1. </p>