Interactive Scatterplots of Census Data Using ggvis

[This article was first published on AriLamstein.com » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Today I finished two projects that had been on my mind for a while:

  1. Try out ggvis, the interactive successor to ggplot2
  2. Create interactive scatterplots of census data

You can see the resulting shiny app here. The app lets you create a scatterplot of any pair of demographic variables that ship with the choroplethr package. When you roll over a point, it tells you where it is. It also adds a trend line.

Here are some examples. Note that while the graphics in the app are interactive, these images are static.

State Race vs. Age

As states get whiter, they also get older:

state-white-vs-age

County Age vs. Income

As counties get older, they also get wealthier:

county-age-income

ZIP Race vs. Age

As ZIP Codes (ZCTAs) get more hispanic, they tend to get younger:

zip-hispanic-age

Here are some fun facts I learned from the app:

  • Vermont and Maine are the oldest and whitest states
  • Sumter County, Florida is the oldest county, with a median age of almost 65
  • Manhattan (technically New York County in New York State) has the highest per capita income

After spending some time with the app I now have a lot less confidence in the ZIP data than I used to – too many ZIPs have a median age below 10 or over 90. Presumably that could be addressed by looking at the error bars of the underlying data (a major purpose of the acs package). That just wasn’t the purpose of this project.

The code for the app is available here.

If you see any interesting correlations or outliers, please comment below! I’m also interested in learning about more options for interactive graphics in R. If you know of other libraries for doing similar work, please also leave a comment as well.

LEARN TO MAP CENSUS DATA
Subscribe and get my free email course: Mapping Census Data in R!
100% Privacy. We don’t spam.

The post Interactive Scatterplots of Census Data Using ggvis appeared first on AriLamstein.com.

To leave a comment for the author, please follow the link and comment on their blog: AriLamstein.com » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)