Learn R Programming

nomiShape (version 1.0.0)

centered_barplot: Centered Frequency Bar Plot for Nominal Variables Creates a centered bar plot for discrete nominal variables by placing the most frequent category at the center and progressively less frequent categories alternately to the left and right.

Description

Centered Frequency Bar Plot for Nominal Variables Creates a centered bar plot for discrete nominal variables by placing the most frequent category at the center and progressively less frequent categories alternately to the left and right.

Usage

centered_barplot(df, var, title = NULL, scale = c("count", "percent"))

Value

A ggplot2 object.

Arguments

df

A data frame containing the nominal variable.

var

A character string giving the name of the nominal variable in df.

title

Optional character string specifying the plot title.

scale

Character string specifying the scale of the frequencies: "count" (default) for raw counts or "percent" for percentages.

Examples

Run this code
centered_barplot(categories, "animal")
centered_barplot(categories, "animal", scale = "percent")

Run the code above in your browser using DataLab