plot_freq: Vertical Bar Plot of Frequencies of Counts

Description Usage Arguments Value Examples

View source: R/plot_freq.R

Description

Plot the counts of groups within a vector or list as a horizontal bar plot.

Usage

1
2
3
4
5
6
7
8
9
plot_freq(
  x,
  direct.label = TRUE,
  size = 4,
  label.diff,
  digits = 1,
  top.diff.weight = 0.06,
  ...
)

Arguments

x

A vector or list of elements.

direct.label

logical. If TRUE count + percent labels are placed above bars.

size

The size to plot the text above the bars.

label.diff

The amount to place the labels above the bars. If missing a reasonable guess is attempted.

digits

The number of percent digits to print.

top.diff.weight

A weight to apply to the space between the top bar and the top of the plot area.

...

Other arguments passed to geom_text.

Value

ggplot2 object

Examples

 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
x <- sample(LETTERS, 100, TRUE)
y <- lapply(1:100, function(i) sample(LETTERS[1:10], sample(0:5, 1), TRUE))
y <- sapply(y, function(x) {
    if(identical(x, character(0))) return(NULL)
    x
})

plot_freq(x)
plot_freq(y)

## Example
library(dplyr)
data(presidential_debates_2012)

discoure_markers <- list(
    response_cries = c("\\boh", "\\bah", "\\baha", "\\bouch", "yuk"),
    back_channels = c("uh[- ]huh", "uhuh", "yeah"),
    summons = "hey",
    justification = "because"
)

presidential_debates_2012 %>%
    with(., term_count(dialogue, TRUE, discoure_markers)) %>%
    as_terms() %>%
    plot_freq(size=3) +
        ggplot2::xlab("Number of Tags")

presidential_debates_2012 %>%
    with(., term_count(dialogue, TRUE, discoure_markers)) %>%
    as_terms() %>%
    plot_counts() +
        ggplot2::xlab("Tags")

trinker/termco documentation built on Jan. 7, 2022, 3:32 a.m.