# NOT RUN {
dat <- DATA
## Add a nested/list text column
dat$split <- lapply(dat$state, function(x) {
unlist(strsplit(x, '(?<=[?!.])\\s+', perl = TRUE))
})
unnest_text(dat)
unnest_text(dat, integer.rownames = FALSE)
## Add a second nested integer column
dat$d <- lapply(dat$split, nchar)
# }
# NOT RUN {
unnest_text(dat) # causes error, must supply column explicitly
# }
# NOT RUN {
unnest_text(dat, 'split')
## As a data.table
library(data.table)
dt_dat <- data.table::as.data.table(data.table::copy(dat))
unnest_text(dt_dat, 'split')
# }
# NOT RUN {
unnest_text(dt_dat, 'd')
# }
# NOT RUN {
# }
# NOT RUN {
## As a tibble
library(tibble)
t_dat <- tibble:::as_tibble(dat)
unnest_text(t_dat, 'split')
# }
Run the code above in your browser using DataLab