title: speeding up "pick up first string from unlist" in R
body: <p>I am trying to capture the first string from a list using an explicit loop, as shown in the following code:</p>
  
  <pre><code>for (loop.temp in (1:nrow(temp)))
      {temp[loop.temp,"drug_name_mod"] &lt;- unlist(strsplit(temp[loop.temp,"drug_name"]," "))[1]
       print(paste(loop.temp,nrow(temp),sep="/"))
       flush.console()
      }
  </code></pre>
  
  <p>But I think it is not very efficient, anyway of improving it? Thanks!</p>