title: I'm trying to find the letter count of the longest word in each sentence in R
body: <p><strong>I'm trying to find the letter count of the longest word in each sentence. My code is here</strong></p>
  <pre><code>new_data &lt;- sample_n(data.frame(stringr::sentences), 30)
  new_data
  
  split_data &lt;- data.frame(X = str_remove_all(new_data$stringr..sentences, &quot;\\.&quot;))
  split_data
  
  split_data &lt;- data.frame(X = str_remove_all(split_data$X, &quot;,&quot;))
  split_data
  
  split_data &lt;- strsplit(split_data$X,&quot; &quot;)
  split_data
  
  longest = c()
  i=0
  
  while(i&lt;30){
     i = i + 1
     longest[i] &lt;- as.list(split_data)[[i]]
     longest[i] &lt;- tail(longest[i][order(nchar(longest[i]))], 1)
  }
  </code></pre>