Skip to content

Commit

Permalink
Some cleanup after PR #87 for quanteda compability
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasilge committed Nov 17, 2017
1 parent e3ee8d1 commit fe2295a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#tidytext 0.1.5 [WIP]

* Change how `NA` values are handled in `unnest_tokens` so they no longer cause other columns to become `NA` (#82).
* Update tidiers and casters to align with quanteda v1.0 (#87).

# tidytext 0.1.4

Expand Down
8 changes: 1 addition & 7 deletions R/sparse_casters.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,7 @@ cast_dfm <- function(data, document, term, value, ...) {
term <- quo_name(enquo(term))
value <- quo_name(enquo(value))
m <- cast_sparse(data, !! document, !! term, !! value, ...)
q_version <- unlist(utils::packageVersion("quanteda"))
# quanteda versions <= v0.99.12 do not have as.dfm(m) for dgCMatrix
if (q_version[1] < 1 && q_version[2] == 99 && q_version[3] < 9000) {
methods::new("dfmSparse", m)
} else {
quanteda::as.dfm(m)
}
quanteda::as.dfm(m)
}


Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-sparse-casters.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ test_that("Can cast tables into a sparse TermDocumentMatrix", {
test_that("Can cast tables into a sparse dfm", {
library(methods)
skip_if_not_installed("quanteda")
data("data_corpus_inaugural", package = "quanteda")

d <- cast_dfm(dat, a, b, val)
d2 <- cast_dfm_(dat, "a", "b", "val")
Expand Down

0 comments on commit fe2295a

Please sign in to comment.