quanteda / quanteda.textstats

Textual statistics for quanteda
GNU General Public License v3.0
14 stars 2 forks source link

Error with textstats_dist() #51

Closed jennahgosciak closed 2 years ago

jennahgosciak commented 2 years ago

Hi there,

I'm trying to run the example code for textstats_dist():

dfmat <- dfm(corpus_subset(data_corpus_inaugural, Year > 2000), remove_punct = TRUE, remove = stopwords("english")) (tstat1 <- textstat_simil(dfmat, method = "cosine", margin = "documents"))

I keep getting the following error message:

Error in validityMethod(as(object, superClass)) : object 'packedMatrix_validate' not found

Is there something I'm missing with how to implement this function?

I have quanteda.textstats_0.95 and quanteda_3.2.1.

jennahgosciak commented 2 years ago

When I reinstalled the older versions of the packages there is no problem.

kbenoit commented 2 years ago

I have everything up to date and it works fine, although your use of deprecated arguments produces warnings.

library("quanteda")
#> Package version: 3.2.1
#> Unicode version: 13.0
#> ICU version: 67.1
#> Parallel computing: 10 of 10 threads used.
#> See https://quanteda.io for tutorials and examples.
library("quanteda.textstats")

dfmat <- dfm(corpus_subset(data_corpus_inaugural, Year > 2000), 
             remove_punct = TRUE, remove = stopwords("english")) 
#> Warning: 'dfm.corpus()' is deprecated. Use 'tokens()' first.
#> Warning: '...' should not be used for tokens() arguments; use 'tokens()' first.
#> Warning: 'remove' is deprecated; use dfm_remove() instead
(tstat1 <- textstat_simil(dfmat, method = "cosine", margin = "documents"))
#> textstat_simil object; method = "cosine"
#>            2001-Bush 2005-Bush 2009-Obama 2013-Obama 2017-Trump 2021-Biden
#> 2001-Bush      1.000     0.520      0.541      0.556      0.452      0.562
#> 2005-Bush      0.520     1.000      0.458      0.516      0.435      0.480
#> 2009-Obama     0.541     0.458      1.000      0.637      0.448      0.616
#> 2013-Obama     0.556     0.516      0.637      1.000      0.455      0.606
#> 2017-Trump     0.452     0.435      0.448      0.455      1.000      0.513
#> 2021-Biden     0.562     0.480      0.616      0.606      0.513      1.000

Created on 2022-04-17 by the reprex package (v2.0.1)

I suggest you update R to the latest version and run update.packages(ask = FALSE).

jennahgosciak commented 2 years ago

Ok thanks, I'll try that.