title: Using substring on a column in R
body: <p>How would I use substring to only use the first 3 digits of the postal code in the data sheet?</p>
  
  <pre><code>YEAR    PERSON    POSTALCODE   STORE_ID
  2012    245345    M2H 2I4       20001319
  2012    234324    L6N 3R5       20001319
  2012    556464    L6N 4T5       20001319
  </code></pre>
  
  <p>This is a piece of code I tried, however my data sheet appeared with 0 objects after I added the substring part of the code (I'm guessing I made an extremely dumb mistake):</p>
  
  <pre><code>combined &lt;- merge(df1, df2, by.y="PERSON")
  store1  &lt;- combined[combined$STORE_ID == 20001319 &amp;&amp; substr(combined$POSTALCODE, 1, 3), ]  
  </code></pre>