{"id":32203192,"url":"https://github.com/jjchern/gglorenz","last_synced_at":"2026-02-19T08:35:24.443Z","repository":{"id":56936305,"uuid":"120814574","full_name":"jjchern/gglorenz","owner":"jjchern","description":"Plotting Lorenz curves with the blessing of ggplot2","archived":false,"fork":false,"pushed_at":"2020-07-13T00:58:50.000Z","size":2031,"stargazers_count":31,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-09T20:47:28.710Z","etag":null,"topics":["ggplot-extension","ggplot2"],"latest_commit_sha":null,"homepage":"https://jjchern.github.io/gglorenz/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jjchern.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-08T20:33:23.000Z","updated_at":"2025-11-18T05:48:25.000Z","dependencies_parsed_at":"2022-08-21T01:10:30.068Z","dependency_job_id":null,"html_url":"https://github.com/jjchern/gglorenz","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jjchern/gglorenz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjchern%2Fgglorenz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjchern%2Fgglorenz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjchern%2Fgglorenz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjchern%2Fgglorenz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jjchern","download_url":"https://codeload.github.com/jjchern/gglorenz/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjchern%2Fgglorenz/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29608576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T06:47:36.664Z","status":"ssl_error","status_checked_at":"2026-02-19T06:45:47.551Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ggplot-extension","ggplot2"],"created_at":"2025-10-22T04:33:59.589Z","updated_at":"2026-02-19T08:35:24.437Z","avatar_url":"https://github.com/jjchern.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\neditor_options: \n  chunk_output_type: console\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  warning = FALSE\n)\n```\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/gglorenz)](https://CRAN.R-project.org/package=gglorenz)\n[![Travis-CI Build Status](https://travis-ci.org/jjchern/gglorenz.svg?branch=master)](https://travis-ci.org/jjchern/gglorenz)\n[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/jjchern/gglorenz?branch=master\u0026svg=true)](https://ci.appveyor.com/project/jjchern/gglorenz)\n\u003c!-- badges: end --\u003e\n\n# About `gglorenz`\n\nThe goal of `gglorenz` is to plot Lorenz Curves with the blessing of `ggplot2`.\n\n# Installation\n\n```R\n# Install the CRAN version\ninstall.packages(\"gglorenz\")\n\n# Install the development version from GitHub:\n# install.packages(\"remotes\")\nremotes::install_github(\"jjchern/gglorenz\")\n```\n\n# Example\n\nSuppose you have a vector with each element representing the amount of income or wealth of an individual, and you are interested in knowing how much of that is produced by the top x% of the population, then the `gglorenz::stat_lorenz(desc = TRUE)` would make a ggplot2 graph for you.\n\n```{r}\nlibrary(tidyverse)\nlibrary(gglorenz)\n\nbillionaires\n\nbillionaires %\u003e%\n    ggplot(aes(TNW)) +\n    stat_lorenz(desc = TRUE) +\n    coord_fixed() +\n    geom_abline(linetype = \"dashed\") +\n    theme_minimal() +\n    hrbrthemes::scale_x_percent() +\n    hrbrthemes::scale_y_percent() +\n    hrbrthemes::theme_ipsum_rc() +\n    labs(x = \"Cumulative Percentage of the Top 500 Billionaires\",\n         y = \"Cumulative Percentage of Total Net Worth\",\n         title = \"Inequality Among Billionaires\",\n         caption = \"Source: https://www.bloomberg.com/billionaires/ (accessed February 8, 2018)\")\n\nbillionaires %\u003e%\n    filter(Industry %in% c(\"Technology\", \"Real Estate\")) %\u003e%\n    ggplot(aes(x = TNW, colour = Industry)) +\n    stat_lorenz(desc = TRUE) +\n    coord_fixed() +\n    geom_abline(linetype = \"dashed\") +\n    theme_minimal() +\n    hrbrthemes::scale_x_percent() +\n    hrbrthemes::scale_y_percent() +\n    hrbrthemes::theme_ipsum_rc() +\n    labs(x = \"Cumulative Percentage of Billionaires\",\n         y = \"Cumulative Percentage of Total Net Worth\",\n         title = \"Real Estate is a Relatively Equal Field\",\n         caption = \"Source: https://www.bloomberg.com/billionaires/ (accessed February 8, 2018)\")\n```\n\nIf you have a data frame with columns indicating the wealth and number of individuals at that level you can use the `n` aesthetic like so: `ggplot(freqdata, aes(x = value, n = freq) + stat_lorenz()`.\n\nIn addition, the `annotate_ineq()` function allows you to label the chart with inequality statistics such as the Gini coefficient:\n\n```{r}\nbillionaires %\u003e%\n    ggplot(aes(TNW)) +\n    stat_lorenz(desc = TRUE) +\n    coord_fixed() +\n    geom_abline(linetype = \"dashed\") +\n    theme_minimal() +\n    hrbrthemes::scale_x_percent() +\n    hrbrthemes::scale_y_percent() +\n    hrbrthemes::theme_ipsum_rc() +\n    labs(x = \"Cumulative Percentage of the Top 500 Billionaires\",\n         y = \"Cumulative Percentage of Total Net Worth\",\n         title = \"Inequality Among Billionaires\",\n         caption = \"Source: https://www.bloomberg.com/billionaires/ (accessed February 8, 2018)\") +\n    annotate_ineq(billionaires$TNW)\n```\n\nYou can also use other geoms such as `area` or `polygon` and arranging population in ascending order:\n\n```{r}\nbillionaires %\u003e%\n    filter(Industry %in% c(\"Technology\", \"Real Estate\")) %\u003e% \n    add_row(Industry = \"Perfect Equality\", TNW = 1) %\u003e% \n    ggplot(aes(x = TNW, fill = Industry)) +\n    stat_lorenz(geom = \"area\", alpha = 0.65) +\n    coord_fixed() +\n    hrbrthemes::scale_x_percent() +\n    hrbrthemes::scale_y_percent() +\n    hrbrthemes::theme_ipsum_rc() +\n    theme(legend.title = element_blank()) +\n    labs(x = \"Cumulative Percentage of Billionaires\",\n         y = \"Cumulative Percentage of Total Net Worth\",\n         title = \"Real Estate is a Relatively Equal Field\",\n         caption = \"Source: https://www.bloomberg.com/billionaires/ (accessed February 8, 2018)\")\n\nbillionaires %\u003e%\n    filter(Industry %in% c(\"Technology\", \"Real Estate\")) %\u003e% \n    mutate(Industry = forcats::as_factor(Industry)) %\u003e% \n    ggplot(aes(x = TNW, fill = Industry)) +\n    stat_lorenz(geom = \"polygon\", alpha = 0.65) +\n    geom_abline(linetype = \"dashed\") +\n    coord_fixed() +\n    hrbrthemes::scale_x_percent() +\n    hrbrthemes::scale_y_percent() +\n    hrbrthemes::theme_ipsum_rc() +\n    theme(legend.title = element_blank()) +\n    labs(x = \"Cumulative Percentage of Billionaires\",\n         y = \"Cumulative Percentage of Total Net Worth\",\n         title = \"Real Estate is a Relatively Equal Field\",\n         caption = \"Source: https://www.bloomberg.com/billionaires/ (accessed February 8, 2018)\")\n```\n\n# Acknowledgement\n\nThe package came to exist solely because Bob Rudis was [generous enough](https://github.com/hrbrmstr/ggalt/issues/46) to write a chapter that [demystifies `ggplot2`.](https://rud.is/books/creating-ggplot2-extensions/demystifying-ggplot2.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjchern%2Fgglorenz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjjchern%2Fgglorenz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjchern%2Fgglorenz/lists"}