title: Extract different words from a character string in R
body: <p>I have seen several SO posts that seem to come close to answering this question but I cannot tell if any actually do so please forgive me is this is a duplicate post. I have several dozens of character strings (this a column within a data frame) that include different numbers, usually written out as words but sometimes as integers. E.g.:</p>
  
  <p><code>Three neonates with one adult</code></p>
  
  <p><code>1 adult, ten neonates nearby</code></p>
  
  <p><code>Two adults and six neonates</code></p>
  
  <p>My ultimate goal is to be able to extract the number of neonates and adults from each string and get something like this:</p>
  
  <p><code>data.frame(Adults=c(1,1,6), Neonates=c(3,10,6)</code></p>
  
  <p>But the number and location of the number within the string varies. All of the examples I have seen using <code>gsub</code>, <code>strsplit</code>, etc. seem to only work when the pattern used to substitute, split, extract, etc. is the same across strings or stays in a constant position within the string. Since I know that the numbers must be <code>c("one","two",...,"ten")</code>, I could possibly loop through every character string and then loop through every possible number to see if it is present within the string and then, if present, extract it and convert to numeric. But this seems very inefficient.</p>
  
  <p>Any help would be most appreciated!!</p>