title: Saving the output of a str_which loop in R
body: <p>I work with a sheet of data that lists a variety of scientific publications. Rows are publications,
  columns are a variety of metrics describing each publication (author name and position, Pubmed IDs, Date etc...)
  I want to filter for publications for each author and extract parts of them. The caveat is the format:
  all author names (5-80 per cell) are lumped together in one cell for each row.</p>
  
  <p>I managed to solve this with the use of <code>str_which</code>, saving the coordinates for each author and later extract. This works only for manual use. When I try to automate this process using a loop to draw on a list of authors I fail to save the output. </p>
  
  <p>I am at a bit of a loss on how to store the results without overwriting previous ones.</p>
  
  <pre><code>sampleDat &lt;- 
    data.frame(var1 = c("Doe J, Maxwell M, Kim HE", "Cronauer R, Carst W, Theobald U", "Theobald U, Hey B, Joff S"),
               var2 = c(1:3),
               var3 = c("2016-01", "2016-03", "2017-05"))
  </code></pre>
  
  <p>list of names that I want the coordinates for</p>
  
  <pre><code>namesOfInterest &lt;-
    list(c("Doe J", "Theobald U"))
  </code></pre>
  
  <p>the manual extraction, requiring me to type the exact name and output object</p>
  
  <pre><code>Doe &lt;- str_which(sampleDat$var1, "Doe J")           
  Theobald &lt;- str_which(sampleDat$var1, "Theobald U") 
  </code></pre>
  
  <p>one of many attempts that does not replicate the manual version.</p>
  
  <pre><code>results &lt;- c()
  
  for (i in namesOfInterest) {
    results[i] &lt;- str_which(sampleDat$var1, i)
  }
  </code></pre>