dgrtwo / tidy-text-mining

Manuscript of the book "Tidy Text Mining with R" by Julia Silge and David Robinson
http://tidytextmining.com
Other
1.32k stars 805 forks source link

Change in cast_sparse and dfm? #5

Closed juliasilge closed 7 years ago

juliasilge commented 8 years ago

When I am building the book locally, I see a difference in how Chapter 6 (casting/tidying) builds between my desktop, which has the development version of tidytext, and my laptop, which has the CRAN version. Travis is currently building with the CRAN version, but we are planning on doing a release ASAP, obviously.

The chapter errors when it tries to cast on the dfm example:

# cast into quanteda's dfm
ap_td %>%
  cast_dfm(term, document, count)

Here's the error:

Quitting from lines 137-144 (06-document-term-matrices.Rmd) 
Error in UseMethod("ndoc") : 
  no applicable method for 'ndoc' applied to an object of class "dfmSparse"
Calls: local ... <Anonymous> -> print -> print -> .local -> cat -> format -> ndoc
Execution halted

The very annoying thing is that I cannot reproduce the error when I run this all interactively; I only get the error when building the book. If I have the file open and say "Run All Chunks Above", then step through the chunk that contains this code, no problems.

juliasilge commented 7 years ago

I switched the book to install tidytext from GitHub in commit e32c7c9c3e5afa91c8b12efe9a8ca271c4521128, thinking I would double-check what is going on here and get ready for the next CRAN release; everything built fine and we are not seeing this error at all. So put this on the back burner and let's not worry about it. I am still not sure why I am getting this error locally (only when building the book, not when running the same code interactively) but I'm going to close this.

juliasilge commented 7 years ago

I wonder if it's related to the version of bookdown I have...

juliasilge commented 7 years ago

Uggggggggh, this started happening for me again. My version of bookdown is totally up-to-date, and I cannot figure out why/what is going on. Same exact problem. So I can't the book to build locally now again. 😞

juliasilge commented 7 years ago

Something related to this is happening again, but now not locally for me, but rather on Travis. Check out this recent build. Mysteriously, the whole book builds just fine for me locally right now!

Just for kicks, I tried deleting the cache on Travis and starting from scratch and we still get this error. Here it is:

Quitting from lines 177-184 (06-document-term-matrices.Rmd) 
Error in getClass(Class, where = topenv(parent.frame())) : 
  "dfmSparse" is not a defined class

I haven't gotten a chance to really dig into this much, but it happens in the chunk when we try to cast to quanteda's dfm. Would it be better to accept Kenneth's PR and do any necessary editing here, then see what is still happening? Thoughts?

juliasilge commented 7 years ago

WELP, this is working again.

I... have no idea, Dave.

juliasilge commented 7 years ago

We solved this by adding library(methods).