Tidytext error summarise

Hi!, i don't how to solve this problem:

texto_token = texto %>%
unnest_tokens(ngram, txt, token = "ngrams", n = 2)

Error in UseMethod("summarise_") : no applicable method for 'summarise_' applied to an object of class "character"

Thanks for your replyment!

Can you provide a reprex or something so that we can work with some data?

No don't know how to use reprex on this web site, but i try to write all the code. I think that this error derives from the package.

library(pdftools)
library(tidyverse)
library(tidytext)

texto = pdf_text("/home/y---p---/Downloads/morel.pdf")

for (i in 1:length(texto)) {
texto[i] = str_replace_all(texto[i],"\n", "")
}

texto_token = texto[1] %>%
unnest_tokens(ngram, txt, token = "ngrams", n = 2)

The book that i analyze is morel.pdf (454.6 KB)

A minimal REPRoducible EXample (reprex) makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ:

1 Like
texto_token <- texto[1] %>% enframe %>%
  unnest_tokens(output=ngram,
                input=value, 
                token = "ngrams",
                n = 2)
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.