I would like to find and extract the longest word of a string, if possible, using a package tidyverse.
library(tidyverse)
tbl <- tibble(a=c("ab cde", "bcde f", "cde fg"), b=c("cde", "bcde", "cde"))
tbl
a
<chr>
1 ab cde
2 bcde f
3 cde fg
As a result, I am looking for:
a b
<chr> <chr>
1 ab cde cde
2 bcde f bcde
3 cde fg cde
The closest message to the question I found is this: the longest word in a line . Anyone have an idea for an even simpler way?
source
share