ranking: GLP Ranking

View source: R/ranking.R

rankingR Documentation

GLP Ranking

Description

Creates a peer city ranking graph using a GLP-style data frame. Columns FIPS is a required column. Columns year, sex, and race are optional columns.

Usage

ranking(
  df,
  var,
  plot_title = "",
  year = NULL,
  sex = "total",
  race = "total",
  peers = "Current",
  order = "Descending",
  y_title = "Percent",
  caption_text = "",
  subtitle_text = "",
  bar_label = TRUE,
  sigfig = 3,
  accuracy = 0.1,
  label_function,
  alternate_text = NULL,
  ranking_colors = TRUE
)

ranking_data(
  df,
  variables,
  years = "",
  sex = "total",
  race = "total",
  descending = TRUE,
  peers = "Current",
  new_vars = ""
)

Arguments

df

A data frame

var

The variable name, can be quoted or unquoted

plot_title

Plot title

year

The year of observations to use. Defaults to the most recent year of data available for var in df.

sex

Filters df using the sex column, if present. Defaults to total, or can be male or female

race

Filters df using the race column, if present. Defaults to total, or can be white, black, hispanic, asian, or other.

peers

Current or Baseline

order

Descending or Ascending

y_title

Y-axis title. Defailts to Percent.

caption_text

Caption text in the bottom right of the graph..

subtitle_text

Subtitle text

bar_label

Add labels to bars? Defaults to TRUE

sigfig

Number of significant digits in bar labels.

accuracy

Accuract of bar labels

label_function

A unique label function to be used in place of the default selected based on y_title.

alternate_text

A numeric vector that specifies which, if any, bar labels should be moved to the right side of the bar. This is used to prevent text from being hidden due to small bars.

Details

The parameters are organized into four sections:

  • Required: df, var

  • Filtering and Sorting: year, sex, race, peers, order

  • Add Text: plot_title, y_title, caption_text, subtitle_text

  • Manipulate Bar Labels: bar_label, sigfig, accuracy, label_function, alternate_text

Functions

  • ranking_data(): Outputs ranking data from inside the ranking function

Examples

ranking(education_county, bach_plus, plot_title = "Bachelor's or Higher", caption_text = "GLP")

ranking(jobs_county, median_earnings_gap_bw, plot_title = "Median Earnings", caption_text = "GLP",
        label_function = scales::dollar_format(accuracy = 1), alternate_text = 12:17)


greaterlouisvilleproject/glptools documentation built on Feb. 9, 2025, 11:21 a.m.