Learn R Programming

datacult (version 0.1.0)

bar_chart_checkbox: Bar chart with frequency and data label with percent.

Description

This function builds a bar chart with ggplot2 for a field with checkbox (user can select 2 or more options). Each option is one separated column.

Usage

bar_chart_checkbox(
  data,
  columns,
  sucess = "checked",
  labels = NULL,
  axis_title = "",
  fill = "blue",
  axis_title_axis_size = 22,
  axis_text_axis_size = 22,
  data_label_size = 15,
  sort = TRUE
)

Value

a ggplot2 object

Arguments

data

dataframe object

columns

character vector. Columns to count.

sucess

character scalar. Category indicating the sucess. Defaults to "checked".

labels

character vector.Label of each category. Defaults to NULL.

axis_title

axis y label. Defaults to "".

fill

bar color. Character scale with hexidecimal color ou named color. Defaults to "blue".

axis_title_axis_size

integer scalar. Size of axis labels. Defaults to 22.

axis_text_axis_size

integer scalar. Size of values annotated in axis. Defaults to 22.

data_label_size

integer scalar. Size of data labels. Defaults to 15

sort

logical scalar. If TRUE, the are ordered using frequency. Defaults to TRUE.

Examples

Run this code
df <- data.frame(
 x1 = c("checked", "checked", "unchecked"),
 x2 = c("checked", "unchecked", "checked")
)
bar_chart_checkbox(df, c("x1", "x2"))

Run the code above in your browser using DataLab