title: apply strsplit to specific column in a data.frame
body: <p>I have a large dataframe with classification information. Here is an example:</p>
  
  <pre><code>&gt; d &lt;- data.frame(x = c(1,2,3,4), classification = c("cl1.scl1", "cl2", "cl3-bla", "cl4.subclass2"))
  &gt; d
    x classification
  1 1       cl1.scl1
  2 2            cl2
  3 3        cl3-bla
  4 4  cl4.subclass2
  </code></pre>
  
  <p>Before I do any further processing I need to aggregate the classification information, which means that I have to split the classification strings by "." and take the first token. This is the result I need:</p>
  
  <pre><code>&gt; d
    x classification
  1 1            cl1
  2 2            cl2
  3 3        cl3-bla
  4 4            cl4
  </code></pre>
  
  <p>At the moment I am computing this as follows:</p>
  
  <pre><code>d$classification = unlist(lapply(d$classification, function (x) strsplit(as.character(x), ".", fixed=TRUE)[[1]][1]))
  </code></pre>
  
  <p>This works, but it took me quite a while to figure this out. I assume there is a more elegant solution, which I probably missed. Any suggestions? Thanks!</p>