if (FALSE) {
terms <- list(
I=c("i", "i'm"),
mal=qcv(stinks, dumb, distrust),
articles=qcv(the, a, an),
pronoun=qcv(we, you)
)
with(DATA, trans_cloud(state, person, target.words=terms,
cloud.colors=qcv(red, green, blue, black, gray65),
expand.target=FALSE, proportional=TRUE, legend=c(names(terms),
"other")))
with(DATA, trans_cloud(state, person, target.words=terms,
stopwords=exclude(with(DATA, unique(bag_o_words(state))),
unique(unlist(terms))),
cloud.colors=qcv(red, green, blue, black, gray65),
expand.target=FALSE, proportional=TRUE, legend=names(terms)))
#color the negated phrases opposite:
DATA <- qdap::DATA
DATA[1, 4] <- "This is not good!"
DATA[8, 4] <- "I don't distrust you."
DATA$state <- space_fill(DATA$state, paste0(negation.words, " "),
rm.extra = FALSE)
txt <- gsub("~~", " ", breaker(DATA$state))
rev.neg <- sapply(negation.words, paste, negative.words)
rev.pos <- sapply(negation.words, paste, positive.words)
tw <- list(
positive=c(positive.words, rev.neg[rev.neg %in% txt]),
negative=c(negative.words, rev.pos[rev.pos %in% txt])
)
with(DATA, trans_cloud(state, person,
target.words=tw,
cloud.colors=qcv(darkgreen, red, gray65),
expand.target=FALSE, proportional=TRUE, legend=names(tw)))
DATA <- qdap::DATA ## Reset DATA
}
Run the code above in your browser using DataLab