Description Usage Arguments Value Examples
Transcript apply word length counts.
1 2 3 4 5 6 7 8 | word_length(
text.var,
grouping.var = NULL,
percent = TRUE,
zero.replace = 0,
digits = 2,
...
)
|
text.var |
The text variable. |
grouping.var |
The grouping variables. Default |
percent |
logical. If |
zero.replace |
Value to replace 0 values with. |
digits |
Integer; number of decimal places to round when printing. |
... |
Other arguments passed to |
Returns a list of:
count |
Dataframe of word length counts by grouping variable(s). |
prop |
Dataframe of the proportions of word length counts by grouping variable. |
rnp |
Dataframe of the frequency and proportions of word length counts by grouping variable. |
percent |
The value of percent used for plotting purposes. |
zero.replace |
The value of zero.replace used for plotting purposes. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | ## 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~.)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.