title: How to apply strsplit to a dataframe in R?
body: <p>I have a very similar question to <a href="https://stackoverflow.com/questions/7748149/apply-strsplit-to-specific-column-in-a-data-frame">this one</a>, but I have a more complicated situation.</p>
  
  <p>Here is my sample code:</p>
  
  <pre><code>test = data.frame(x = c(1:4), 
                   y = c("/abc/werts/h1-1234", "/abc/fghye/seths/h2-234",
                             "/abc/gvawrttd/hyeadar/h3-9868", "/abc/qqras/x1-7653"))
  test$y = as.character(test$y)
  </code></pre>
  
  <p>And I want an output like this:</p>
  
  <pre><code>1 h1-1234
  2 h2-234
  3 h3-9868
  4 x1-7653
  </code></pre>
  
  <p>I tried:</p>
  
  <pre><code>test$y = tail(unlist(strsplit(test$y, "/")), 1)
  </code></pre>
  
  <p>However, the result of above codes returned:</p>
  
  <pre><code>1 h1-1234
  2 h1-1234
  3 h1-1234
  4 h1-1234
  </code></pre>
  
  <p>So my question is, how should modified my code so that I can get my desired output?</p>
  
  <p>Thanks in advance!</p>