3

I use quanteda for text analysis

I use this commands

corp_df2 <- 
    tokens(df$text,
           remove_punct = TRUE, 
           remove_numbers = TRUE, 
           remove_symbols = TRUE) %>%
    tokens_remove(pattern = stopwords(source = "smart")) %>%
      tokens_wordstem()

corp_df3 <- dfm(corp_df2) %>%
    dfm_trim(min_termfreq = 0.95, termfreq_type = "quantile") 

myDfm <- dfm(corp_df3, ngrams = c(1,3))

But I receive this error

Argument ngrams not used.

How can I use the command to receive ngrams?

Nathalie
  • 1,228
  • 7
  • 20
  • Can you make this question reproducible by adding example input and expected output ? – Ronak Shah Oct 07 '19 at 03:06
  • 1
    You need to form ngrams from the tokens object, not from the dfm object. Features (columns) from a dfm have no ordering and therefore you cannot form ngrams from a dfm object. – Ken Benoit Oct 07 '19 at 06:19

0 Answers0