Watts-College / cpp-527-fall-2021

A course shell for CPP 527 Foundations of Data Science II
https://watts-college.github.io/cpp-527-fall-2021/
2 stars 6 forks source link

Lab 04 - Part 2 - Frequency of co-occuring words #38

Open Dimetry-Adel opened 2 years ago

Dimetry-Adel commented 2 years ago

Hello everyone,

I am trying to replicate the code provided for counting the frequency of co-occuring words.

# find frequently co-occuring words (typically compound words)
ngram2 <- tokens_ngrams( tokens, n=2 ) %>% dfm()
ngram2 %>% textstat_frequency( n=10 )

However, R keeps giving this error.

Error in textstat_frequency(., n = 10) : 
  could not find function "textstat_frequency"

Does anyone have a solution or explanation?

Thank you in advance.

voznyuky commented 2 years ago

Dimetry,

install and library these packages:

library(quanteda)
library(quanteda.textmodels)
library(quanteda.textstats)
library(quanteda.textplots)

Or you can do:

quanteda.bundle <- c( "quanteda", "quanteda.textmodels",
                      "quanteda.textstats", "quanteda.textplots" )
install.packages( quanteda.bundle )
lecy commented 2 years ago

Did that work @Dimetry-Adel ?

lecy commented 2 years ago

For more details see: https://github.com/Watts-College/cpp-527-fall-2021/issues/32#issuecomment-918355445

Dimetry-Adel commented 2 years ago

Hello Dr. @lecy and @voznyuky, Sorry for the late reply, I had some issues with the internet connection.

After installing and loading the packages. Yes, it works.

Previously, I loaded "quanteda" only.

Many thanks