plotflow (version 0.2.1)

yes_no_bar: Two Choice Horizontal Stacked Bar

Description

Create a two choice horizontal stacked bar chart in the style of base graphics. Default color scheme makes it easy to throw into slides and posters as an infographic style plot.

Usage

yes_no_bar(n.yes, n.no = NULL, n = NULL, labs = c("Yes", "No"),
  digits = 1, fill = c("#51A651", "white"), color = "#CAE4CA",
  border = "grey70", size = 10, include.percent = c(TRUE, FALSE))

Arguments

n.yes

Number yes (integer). User must supply 2 of the first three parameters (n.yes, n.no, or n).

n.no

Number no (integer).

n

Total number (integer).

labs

The labels to use for the two choices that correspond to n.yes and n.no.

digits

Digits to use in the percents.

fill

The bar fill colors

color

The text color.

border

The border color.

size

The text size.

include.percent

A logical vector of 1-2 (if 1 the second will be FALSE) stating if percents should be included. The length of 2 corresponds to the 2 choices; n.yes and n.no. If a single value is given it is recycled.

Value

Returns a ggplot object.

Examples

Run this code
# NOT RUN {
yes_no_bar(111, 66)
yes_no_bar(111, 66, fill=c("pink", "ivory"), color="purple")
yes_no_bar(55, n = 166, labs = c("True", "False"))
yes_no_bar(2345, 3456, labs = c("Boy", "Girl"), fill=c("lightblue", "pink"),
    color="grey50", include.percent = TRUE)
yes_no_bar(2345, 3456, labs = c("Boy", "Girl"), fill=c("lightblue", "pink"),
    color="grey50", include.percent = FALSE)
yes_no_bar(9999, n = 22166, fill=c("green", "pink"),
    labs = c("Go:", "Stop"), color = "grey30", digits=0)
# }

Run the code above in your browser using DataLab