geom_sigmark_total: Significance Markers for ggplot2

Description Usage Arguments Details Note Examples

View source: R/geom_sigmark_total.R

Description

Apply significance markers onto an existing ggplot2 chart

Usage

1
2
3
geom_sigmark_total(tbl_sig, x = "level", y = "pos", group = NULL,
  colour = NULL, direction = "Direction", labels = c("Higher", "Lower"),
  icon = "full triangle", size = 5)

Arguments

tbl_sig

A df object created from tbl_sig functions.

x

A quoted character string of the variable from the 'tbl_sig' df charted on the x-axis. Typically this is "level".

y

A quoted character string of the variable from the 'tbl_sig' df charted on the y-axis. Typically this is "result_pos".

group

An optional quoted character string of the variable from the 'tbl_sig' df that is grouped. If needed, it likely needs to be "group".

colour

A quoted character string of the variable from the 'tbl_sig' df that applies the subgroup colours. Typically this is "level".

direction

A quoted character string of the variable from the 'tbl_sig' df indicating whether the change from one wave to the next is up or down. Typically this is "Direction".

labels

A quoted character string vector indicating how the sig. test markers should be labeled in the legend. By default, the labels are "Increase" and "Decrease".

icon

A quoted character string indicating the type of icon to display to denote statistical significance. Default is "full triangle".

size

A numeric value indicating the size of the icon. Default is set to 5.

Details

This is essentially a wrapper for geom_point

Note

The icon argument accepts one of the following strings:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Proportions
gss_data1 <- dplyr::filter(gss_data, year == "2016",
                           conlegis %in% c("A GREAT DEAL", "ONLY SOME", "HARDLY ANY"))
my_results <- freq_prop_test(gss_data1, "conlegis", "region", level = "E. NOR. CENTRAL", weight = "wtssall")
sig <- tbl_sig(my_results, "region", space_label = 0.05, compare = "total")
chart <- tbl_chart(gss_data1, "conlegis", "region", weight = "wtssall")
chart <- dplyr::filter(chart, region == "E. NOR. CENTRAL")
chart$conlegis <- forcats::fct_relevel(chart$conlegis, "HARDLY ANY", "ONLY SOME", "A GREAT DEAL")

library(ggplot2)
ggplot() +
geom_col(data = chart, aes(x = conlegis, y = prop)) +
	coord_flip() +
	geom_text(data = chart, aes(x = conlegis, y = prop, label = scales::percent(round(prop, 2))), hjust = -0.2) +
	geom_sigmark_total(sig)

philstraforelli/ggsigmark documentation built on April 3, 2018, 12:07 p.m.