ff_plot_demo_line: Line Chart of Demographics

View source: R/visualizations.R

ff_plot_demo_lineR Documentation

Line Chart of Demographics

Description

This function creates a line chart of the given demographic for Forsyth County.

Usage

ff_plot_demo_line(
  data,
  demographic,
  y_axis_title,
  percent = F,
  dollar = F,
  color_palette = "Set 2"
)

Arguments

data

Name of the dataframe with columns outlined above

demographic

String in the 'type' column that signifies the demographic

y_axis_title

Title for y axis and tooltip

percent

Boolean (TRUE / FALSE), whether estimate value is a percent; this will add percent labels to axis

dollar

Boolean (TRUE / FALSE), whether estimate value is a dollar; this will add dollar labels to the axis

color_palette

string representing the color palette to use, possible palettes are qualitative palettes from the <a href="http://library http://colorspace.r-forge.r-project.org/reference/hcl_palettes.html">'colorspace' library</a>.

Details

The input dataset needs to have, at a minimum, columns of the following form and with the following names: - year: year of the data - geo_description: geography (needs Forsyth County as one of the geographies) - type: general description of the demographic identifier (Race and Ethnicity, Total Population, etc) - subtype: specific description of the demographic identifier (African American, Employment Rate, etc) - estimate: value

Value

line chart of the demographic for Forsyth County and all years

Examples

geographies <- c("Forsyth County, NC", "Guilford County, NC", "Durham County, NC",
                 "North Carolina", "United States")
years <- seq(2006, 2017, 1)

df <- data.frame(
    year = rep(years, each=length(geographies)),
    geo_description = rep(geographies, length(years)),
    type = "Total Population",
    subtype = "Employment Rate",
    stringsAsFactors = FALSE
)

df$estimate <- rnorm(nrow(df), mean = .5, sd = .15)

ff_plot_compare_line(data = df,
                    comparison_filter = "Total Population",
                    y_axis_title = "Employment Rate (%)",
                    percent = T,
                    dollar = F,
                    geography_order = c("Forsyth County, NC", "Guilford County, NC", "Durham County, NC",
                                         "North Carolina", "United States"))

forsythfuture/FFtools documentation built on April 5, 2022, 10:02 p.m.