create_lorenz: Calculate the Lorenz Curve and Gini Coefficient in a Person...

View source: R/create_lorenz.R

create_lorenzR Documentation

Calculate the Lorenz Curve and Gini Coefficient in a Person Query

Description

This function computes the Gini coefficient and plots the Lorenz curve based on a selected metric from a Person Query data frame. It provides a way to measure inequality in the distribution of the selected metric.This function can be integrated into a larger analysis pipeline to assess inequality in metric distribution.

Usage

create_lorenz(data, metric, return = "plot")

Arguments

data

Data frame containing a Person Query.

metric

Character string identifying the metric to be used for the Lorenz curve and Gini coefficient calculation.

return

Character string identifying the return type. Options are:

  • "gini" - Numeric value representing the Gini coefficient.

  • "table" - Data frame containing a summary table of population share and value share.

  • "plot" (default) - ggplot object representing a plot of the Lorenz curve.

Examples

create_lorenz(data = pq_data, metric = "Emails_sent", return = "gini")

create_lorenz(data = pq_data, metric = "Emails_sent", return = "plot")

create_lorenz(data = pq_data, metric = "Emails_sent", return = "table")

vivainsights documentation built on Sept. 11, 2024, 5:36 p.m.