# NOT RUN {
(x <- with(DATA, word_length(state, person)))
plot(x)
scores(x)
proportions(x)
counts(x)
plot(scores(x))
plot(proportions(x))
plot(counts(x))
(x2 <- word_length(DATA[["state"]]))
(x2 <- word_length(DATA[["state"]], apostrophe.remove=TRUE))
## Example Visualizations with Presidential Debate Data
library(tidyr)
(x_long <- proportions(x) %>%
gather("Letter_Length", "Proportion", -c(1:2)))
ggplot(x_long, aes(x = Letter_Length, y = Proportion, color=person, group=person)) +
geom_line(size=.8)
(x3 <- with(pres_debates2012, word_length(dialogue, person)))
(x_long2 <- proportions(x3) %>%
gather("Letter_Length", "Proportion", -c(1:2)))
ggplot(x_long, aes(x = Letter_Length, weight = Proportion, fill=person, group=person)) +
geom_bar()
ggplot(x_long, aes(x = Letter_Length, weight = Proportion, fill=person)) +
geom_bar() +
facet_wrap(~person, ncol=1)
ggplot(x_long, aes(x = Letter_Length, weight = Proportion, fill=person)) +
geom_bar() +
coord_flip() +
facet_wrap(~person, ncol=1)
ggplot(x_long, aes(x = person, weight = Proportion)) +
geom_bar(fill="grey40") +
coord_flip() +
facet_grid(Letter_Length~.)
# }
Run the code above in your browser using DataLab