Skip to content

Commit

Permalink
Merge pull request #52 from bstewart/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
bstewart committed Mar 3, 2017
2 parents 09e3423 + b28d44a commit 14313bc
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: stm
Type: Package
Title: Estimation of the Structural Topic Model
Version: 1.2.1
Date: 2017-03-01
Date: 2017-03-03
Author: Margaret Roberts [aut, cre],
Brandon Stewart [aut, cre],
Dustin Tingley [aut, cre],
Expand Down
4 changes: 2 additions & 2 deletions R/stm-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ NULL
#' @docType data
#' @format A data frame with 351 observations on the following 3 variables.
#' \describe{
#' \item{\code{MetaID"}}{A numeric vector containing identification
#' \item{\code{MetaID}}{A numeric vector containing identification
#' numbers; not used for analysis}
#' \item{\code{treatment}}{A numeric vector
#' indicating treatment condition}
#' \item{\code{pid_rep"}}{A numeric vector of
#' \item{\code{pid_rep}}{A numeric vector of
#' party identification}
#' \item{\code{open.ended.response}}{A character vector
#' of the subject's open ended response}
Expand Down
3 changes: 3 additions & 0 deletions R/stm.R
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,14 @@
#' prevalence=~treatment + s(pid_rep), data=out$meta)
#'
#' #The same example using quanteda instead of tm via textProcessor()
#' #Note this example works with quanteda version 0.9.9-31 and later
#' require(quanteda)
#' gadarian_corpus <- corpus(gadarian, text_field = "open.ended.response")
#' gadarian_dfm <- dfm(gadarian_corpus,
#' remove = stopwords("english"),
#' stem = TRUE)
#' stm_from_dfm <- stm(gadarian_dfm, K = 3, prevalence = ~treatment + s(pid_rep),
#' data = docvars(gadarian_corpus))
#'
#' #An example of restarting a model
#' mod.out <- stm(out$documents, out$vocab, 3, prevalence=~treatment + s(pid_rep),
Expand Down
4 changes: 2 additions & 2 deletions man/gadarian.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/stm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added tests/testthat/Rplots.pdf
Binary file not shown.
27 changes: 16 additions & 11 deletions tests/testthat/test-quanteda-stm.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ require(quanteda)

test_that("Test that stm works on a quanteda dfm", {
require(quanteda)
gadarian_corpus <- corpus(gadarian, text_field = "open.ended.response")
gadarian_dfm <- dfm(gadarian_corpus,
remove = stopwords("english"),
stem = TRUE)
set.seed(10012) # NYU :-)
stm_from_dfm <- stm(gadarian_dfm,
K = 3,
prevalence = ~treatment + s(pid_rep),
data = docvars(gadarian_corpus),
max.em.its=2)
expect_identical(class(stm_from_dfm), "STM")
if(utils::compareVersion(as.character(utils::packageVersion("quanteda")), "0.9.9-31") >= 0) {
gadarian_corpus <- corpus(gadarian, text_field = "open.ended.response")
gadarian_dfm <- dfm(gadarian_corpus,
remove = stopwords("english"),
stem = TRUE)
set.seed(10012) # NYU :-)
stm_from_dfm <- stm(gadarian_dfm,
K = 3,
prevalence = ~treatment + s(pid_rep),
data = docvars(gadarian_corpus),
max.em.its=2)
expect_identical(class(stm_from_dfm), "STM")
} else {
#basically if the version is old, just skip this test for now.
expect_identical("STM", "STM")
}
})

test_that("Test that stm works on a classic stm object structure", {
Expand Down

0 comments on commit 14313bc

Please sign in to comment.