library(Hmisc) # for cut2
# States with greater than 1M residents
df = get_acs_df("B01003", "state") # population
df.map = bind_df_to_map(df, "state")
df.map$value = cut2(df.map$value, cuts=c(0,1000000,Inf))
render_choropleth(df.map, "state", "States with a population over 1M", "Population")
# Counties with greater than or greater than 1M residents
df = get_acs_df("B01003", "county") # population
df.map = bind_df_to_map(df, "county")
df.map$value = cut2(df.map$value, cuts=c(0,1000000,Inf))
render_choropleth(df.map, "county", "Counties with a population over 1M", "Population")
# ZIP codes in California where median age is between 20 and 30
df = get_acs_df("B01002", "zip") # median age
df = df[df$value >= 20 & df$value <= 30, ]
df$value = cut2(df$value, g=3) # 3 equally-sized groups
df.map = bind_df_to_map(df, "zip")
render_choropleth(df.map,
"zip",
title = "CA Zip Codes by Age",
scaleName = "Median Age",
states = "CA")Run the code above in your browser using DataLab