stmBrowser: Outputs json file and creates visualization from stm.

Description Usage Arguments Value See Also Examples

View source: R/stmBrowser.R

Description

This function outputs necessary json files to a working directory, then opens a browser with the visualization of the relationship between covariates and topics in the stm.

Usage

1
2
stmBrowser(mod, data, covariates, text, id = NULL,
     n = 1000, labeltype ="prob", directory=getwd())

Arguments

mod

STM model output.

data

Data associated with the stm model

covariates

Names of covariates you are interested in plotting.

text

Name of the variable within the dataset that corresponds to the text.

id

Name of ID variable for each observation.

n

Number of observations to plot. Maximum is 5000.

labeltype

Type of label for topics (see labelTopics in the stm package for more information)

directory

Directory where the stm visualization should be outputted. Default is the current working directory.

Value

The html file for the browser will be written to the folder the user selects as index.html. The user can open this webpage to view the browser.

See Also

stm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(stm)
data(poliblog5k)
#Create date
dec312007 <- as.numeric(as.Date("2007-12-31"))
poliblog5k.meta$date <- as.Date(dec312007+poliblog5k.meta$day,
                                                          origin="1970-01-01")
out <- prepDocuments(poliblog5k.docs, poliblog5k.voc, poliblog5k.meta)
stm.out <- stm(out$documents, out$vocab, K=10,
                              prevalence=~rating + date,
                              data=out$meta,
                              max.em.its=1) #generally run models
                                        #longer than this.
library(stmBrowser)
setwd(tempdir())
stmBrowser(stm.out, data=out$meta, c("rating", "date"),
                   text="text")
#Remove files
unlink("stm-visualization", recursive=TRUE)

stmBrowser documentation built on May 29, 2017, 11:58 a.m.