title: R extract first number from string
body: <p>I have a string in a variable which we call v1. This string states picture numbers and takes the form of "Pic 27 + 28". I want to extract the first number and store it in a new variable called item.</p>
  
  <p>Some code that I've tried is:</p>
  
  <pre><code>item &lt;- unique(na.omit(as.numeric(unlist(strsplit(unlist(v1),"[^0-9]+")))))
  </code></pre>
  
  <p>This worked fine, until I came upon a list that went:</p>
  
  <pre><code>[1,] "Pic 26 + 25"
  [2,] "Pic 27 + 28"
  [3,] "Pic 28 + 27"
  [4,] "Pic 29 + 30"
  [5,] "Pic 30 + 29"
  [6,] "Pic 31 + 32"
  </code></pre>
  
  <p>At this point I get more numbers than I want, as it is also grabbing other unique numbers (the 25).</p>
  
  <p>I've actually tried doing it with gsub, but got nothing to work. Help would be appreciated greatly!</p>