# NOT RUN {
if (requireNamespace("textfeatures", quietly = TRUE)) {
library(recipes)
library(modeldata)
data(okc_text)
okc_rec <- recipe(~ ., data = okc_text) %>%
step_textfeature(essay0)
okc_obj <- okc_rec %>%
prep()
juice(okc_obj) %>%
slice(1:2)
juice(okc_obj) %>%
pull(textfeature_essay0_n_words)
tidy(okc_rec, number = 1)
tidy(okc_obj, number = 1)
# Using custom extraction functions
nchar_round_10 <- function(x) round(nchar(x) / 10) * 10
recipe(~ ., data = okc_text) %>%
step_textfeature(essay0,
extract_functions = list(nchar10 = nchar_round_10)) %>%
prep() %>%
juice()
}
# }
Run the code above in your browser using DataLab