count_vars_plot: Count variable for plotting

View source: R/count.R

count_vars_plotR Documentation

Count variable for plotting

Description

This function count variables, do fct_reorder by that count, extract percentage and construct labels column ready to be plotted.

Usage

count_vars_plot(
  x,
  ...,
  var_desc = TRUE,
  label_number = c("percent", "count", "both"),
  lump_prop = 0,
  other_level = "Other"
)

Arguments

x

A data.frame

...

(Quoted or Unquoted) Variables to count

var_desc

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

label_number

Construction of labels column in the output

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

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

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

lump_prop

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

other_level

Name of the "Other" level

Value

A data.frame with "n", "prop", "pc", "labels" column

Examples

count_vars_plot(iris, Species)

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