View source: R/visualizations.R
ff_plot_compare | R Documentation |
This function creates a bar and line chart of comparison communities for a given aggregate metric. The most recent year's data will be returned in the bar chart.
ff_plot_compare( data, comparison_filter, line_axis_title, bar_axis_title, percent = F, dollar = F, geography_order = c("Forsyth County, NC", "Guilford County, NC", "Durham County, NC", "North Carolina", "United States") )
data |
Name of the dataframe with columns outlined above |
comparison_filter |
String in the 'type' column that signifies the rows that are needed for this plot, Will generally be rows of total aggregate value |
line_axis_title |
Title for y axis and tooltip of line chart |
bar_axis_title |
Title for x axis and tooltip for bar chart |
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 |
geography_order |
Vector of strings that sets the geography order of the legend |
The input dataset needs to have columns of the following form, and with the following names: - year: year of the data - geo_description: geography - 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
bar plot of the most recent year of data followed by a line chart
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(data = df, comparison_filter = "Total Population", line_axis_title = "Employment Rate (%)", bar_axis_title = "2017 Employment Rate (%)", percent = T, dollar = F, geography_order = c("Forsyth County, NC", "Guilford County, NC", "Durham County, NC", "North Carolina", "United States"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.