util_bar_plot {dataquieR}R Documentation

Utility function to create bar plots

Description

A helper function for simple bar plots. The layout is intended for data with positive numbers only (e.g., counts/frequencies).

Usage

util_bar_plot(
  plot_data,
  cat_var,
  num_var,
  relative = FALSE,
  show_numbers = TRUE,
  fill_var = NULL,
  colors = "#2166AC",
  show_color_legend = FALSE,
  flip = FALSE
)

Arguments

plot_data

the data for the plot. It should consist of one column specifying the categories, and a second column giving the respective numbers / counts per category. It may contain another column to specify the coloring of the bars (fill_var).

cat_var

column name of the categorical variable in plot_data

num_var

column name of the numerical variable in plot_data

relative

if TRUE, numbers will be interpreted as percentages (values in num_var should lie within ⁠[0,1]⁠)

show_numbers

if TRUE, numbers will be displayed on top of the bars

fill_var

column name of the variable in plot_data which will be used to color the bars individually

colors

vector of colors, or a single color

show_color_legend

if TRUE, a legend for the colors will be displayed

flip

if TRUE, bars will be oriented horizontally

Value

a bar plot


[Package dataquieR version 2.5.1 Index]