term_match(raj$dialogue, c(" love ", "love", " night ", "night"))
dispersion_plot(raj$dialogue, c(" love ", "love", " night ", "night"))
dispersion_plot(raj$dialogue, c("love", "night"), rm.vars = raj$act)
with(rajSPLIT , dispersion_plot(dialogue, c("love", "night"),
grouping.var = list(fam.aff, sex), rm.vars = act))
## With grouping variables
with(rajSPLIT , dispersion_plot(dialogue, c("love", "night"),
grouping.var = sex, rm.vars = act))
## Drop total with `total.color = NULL`
with(rajSPLIT , dispersion_plot(dialogue, c("love", "night"),
grouping.var = sex, rm.vars = act, total.color = NULL))
## Change color scheme
with(rajSPLIT, dispersion_plot(dialogue, c("love", "night"),
bg.color = "black", grouping.var = list(fam.aff, sex),
color = "yellow", total.color = "white", horiz.color="grey20"))
## Use word list
## Presidential debates by all
wrds <- word_list(pres_debates2012$dialogue, stopwords = Top200Words)
wrds2 <- spaste(wrds[["rfswl"]][["all"]][, "WORD"])
wrds2 <- c(" governor~~romney ", wrds2[-c(3, 12)])
with(pres_debates2012 , dispersion_plot(dialogue, wrds2, rm.vars = time))
## Presidential debates by person
dat <- pres_debates2012
dat <- dat[dat$person %in% qcv(ROMNEY, OBAMA), ]
wordlist <- c(" tax", " health", " rich ", "america", " truth",
" money", "cost", " governnor", " president", " we ",
" job", " i ", " you ", " because ", " our ", " years ")
with(dat, dispersion_plot(dialogue, wordlist, total.color = NULL,
bg.color = "white", grouping.var = person, rm.vars = time,
color = "black", horiz.color="grey80"))
## Extras:
## Reverse facets
x <- with(pres_debates2012 , dispersion_plot(dialogue, wrds2, rm.vars = time))
## function to reverse ggplot2 facets
rev_facet <- function(x) {
names(x$facet)[1:2] <- names(x$facet)[2:1]
print(x)
}
rev_facet(x)
Run the code above in your browser using DataLab