Learn R Programming

nomiShape (version 1.0.0)

shape_comp_plot: Compare Observed Nominal Distribution with Theoretical Shapes

Description

Plots a centered dotplot of a nominal variable and overlays four theoretical distributions: uniform, triangular, exponential (Pareto-like), and normal-like.

Usage

shape_comp_plot(df, var, rate_exp = 0.7, scale = c("count", "percent"))

Value

A ggplot2 object.

Arguments

df

A data.frame or tibble containing the nominal variable.

var

Character string giving the name of the nominal variable in df.

rate_exp

Numeric. Rate parameter for the exponential distribution (Pareto-like). Default is 0.7.

scale

Character. Whether to scale frequencies as counts ("count") or percentages ("percent"). Default is "count".

Details

The function orders categories from most frequent at the center outwards. Observed frequencies are plotted as points and lines, and each theoretical distribution is overlaid with a different color and line type.

Examples

Run this code
shape_comp_plot(categories, "animal")
shape_comp_plot(categories2, "animal")
shape_comp_plot(categories3, "animal")

Run the code above in your browser using DataLab