How to create drill-down graphs with highcharter in R

Drill-down visualizations can be a good way to present a lot of data in a digestible format. In this example, we’ll create a graph of median home values by U.S. state using R and the highcharter package.

Median home values by state Sharon Machlis, IDG

Initial graph of median home values by state (highest and lowest 10 states). Data from Zillow.

Each state’s bar will be clickable — the drilldown — to see data by county.

Graph of median home values in Massachusetts counties Sharon Machlis, IDG

After clicking the bar for Massachusetts, a user sees median home values by Massachusetts county. Data from Zillow.

There are three main steps to making a drill-down graph with highcharter:

  1. Wrangle your data into the necessary format; 
  2. Create a basic top-level graph; and 
  3. Add the drill-down.

If you want to follow along, download state- and county-level data sets for the Zillow Home Value Index from Zillow at I’m using the ZHVI Single-Family Homes series.

First, load the packages we’ll be using:

Copyright © 2020 IDG Communications, Inc.

Source link


Please enter your comment!
Please enter your name here