View source: R/visualizations.R
| ff_plot_demo | R Documentation |
This function creates a bar and line chart of a given demographic data within Forsyth County.
ff_plot_demo( data, demographic, line_axis_title, bar_axis_title, percent = F, dollar = F, color_palette = "Set 2" )
data |
Name of the dataframe with columns outlined above |
demographic |
String in the 'type' column that signifies the demographic |
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 |
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>. |
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
bar and line plot of the most recent year of data
years <- seq(2006, 2017, 1)
df <- data.frame(
year = rep(2017, 3),
geo_description = rep("Forsyth County, NC", 3),
type = rep("Race and Ethnicity", 3),
subtype = c("African American", "White", "Hispanic / Latino"),
estimate = rnorm(3, mean = .5, sd = .15),
stringsAsFactors = FALSE
)
ff_plot_demo(data = df,
demographic = "Race and Ethnicity",
line_axis_title = "Employment Rate (%)",
bar_axis_title = "2017 Employment Rate (%)",
percent = T,
dollar = F)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.