Learn R Programming

datacult (version 0.1.0)

bar_chart: Bar chart with horizontal bar and data label.

Description

Axis-x has the frequency and data label has the percent value.

Usage

bar_chart(
  data,
  variable,
  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

a dataframe object

variable

variable name

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(var = sample(c("A", "B"),
 size = 100, replace = TRUE))
bar_chart(df, var)

Run the code above in your browser using DataLab