plot_bar: Plot Counted Bar Graph

View source: R/plot_count.R

plot_barR Documentation

Plot Counted Bar Graph

Description

Plot counted of 1 variable using bar graph

Usage

plot_bar(
  data,
  var,
  var_desc = TRUE,
  lump_prop = 0,
  other_level = "Other",
  alpha = 0.8,
  stat = c("percent", "prop", "count"),
  label_geom = c("label", "label_repel", "text", "text_repel"),
  label_number = c("percent", "count", "both"),
  ...
)

Arguments

data

A data.frame

var

(Quote or Unquote) Categorical variables to plot

var_desc

If TRUE levels of the variable will be reorder in descending order according to count of that variable

lump_prop

Proportion that lump levels to "Other" (passed to fct_lump at prop argument)

other_level

Name of the "Other" level

alpha

An alpha of geom_col

stat

(A Character) How y-axis computed ?

  • "percent": as percentage with ⁠%⁠

  • "prop": as proportion

  • "count": as count

label_geom

(A Character) Indicate function of label geom

  • "label": geom_label

  • "label_repel": ggrepel::geom_label_repel

  • "text": geom_text

  • "text_repel": ggrepel::geom_text_repel

label_number

(A Character) How to display the label?

  • "percent": use ⁠%⁠ (eg. 60%)

  • "count": count as integer (eg. 6)

  • "both": use ⁠%⁠ and count in parenthesis (eg. 60% (6))

...

Passed to selected function of label_geom

Value

A Plot class gg and ggplot

Examples

plot_bar(mtcars, cyl)

Lightbridge-KS/lbx documentation built on Dec. 4, 2024, 2:53 a.m.