title: R - gsub only digits
body: <p>I would like to clean this vector and only retain the digits </p>
  
  <pre><code>vec = c(" 4010  \"Filling in time budget diary\"", " 8888  \"Prob cont. preceding activity\"", " 9999   \"Missing, undecipherable\";") 
  </code></pre>
  
  <p>what I would like is simply : <code>4010, 8888, 9999</code></p>
  
  <p>I thought of something like, matching exactly the digits but it doesn't work. </p>
  
  <pre><code>gsub("^[[:digit:]]$", replacement = '', vec)
  </code></pre>
  
  <p>Thanks </p>