Learn R Programming

nomiShape (version 1.0.2)

zipf_rank_plot: Rank-frequency (Zipf) plot for nominal variables

Description

Generates a rank-frequency plot comparing observed category frequencies with the expected Zipf distribution (inverse rank relationship).

Usage

zipf_rank_plot(df, var, max_rank = NULL, top_prop = NULL, loglog = FALSE)

Value

Invisibly returns a data frame with rank-frequency information.

Arguments

df

A data frame containing the nominal variable.

var

Character string specifying the nominal variable column.

max_rank

Maximum number of ranks to display. If NULL (default), all ranks are shown.

top_prop

Proportion of total observations to retain (0–1). If set, only the most frequent categories accounting for this cumulative proportion are displayed. Overrides max_rank.

loglog

Logical. If TRUE, both axes are displayed on a log10 scale.

Examples

Run this code
zipf_rank_plot(kafka, "word")
zipf_rank_plot(alice, "word", loglog=TRUE)
zipf_rank_plot(alice, "word", max_rank = 250)

Run the code above in your browser using DataLab