Separate one word per column
Arguments
- df
A tidy data frame containing a column called "ngram"
- names_prefix
The prefixed name of the new columns, as in "word_1", "word_2", etc.
- ...
Additional options passed to
tidyr::separate_wider_delim()
See also
Other n-gram helpers:
add_ngrams()
,
combine_ngrams()
,
plot_bigrams()
Examples
if (FALSE) { # \dontrun{
my_corpus <- load_texts(n = 2)
my_bigrams <- my_corpus |>
separate_ngrams()
} # }
dubliners <- get_gutenberg_corpus(2814) |>
load_texts() |>
identify_by(part) |>
standardize_titles()
dubliners |>
add_ngrams() |>
combine_ngrams() |>
separate_ngrams() |>
head()
#> # A tibble: 6 × 6
#> doc_id title author part word_1 word_2
#> <fct> <chr> <chr> <chr> <chr> <chr>
#> 1 The Sisters Dubliners Joyce, James THE SISTERS there was
#> 2 The Sisters Dubliners Joyce, James THE SISTERS was no
#> 3 The Sisters Dubliners Joyce, James THE SISTERS no hope
#> 4 The Sisters Dubliners Joyce, James THE SISTERS hope for
#> 5 The Sisters Dubliners Joyce, James THE SISTERS for him
#> 6 The Sisters Dubliners Joyce, James THE SISTERS him this