How to Create Waffle Charts in R
Waffle charts are an effective alternative to other proportional chart styles. Learn how to create these visually appealing charts in R.
A waffle chart can help us analyze data from the National Parks Service to understand which parts of the Grand Canyon get the highest number of visitors.
Step 1: Prep the data
Download the csv and manually remove the header. Add 1 temporary column name to load the data into R without errors.
Step 2: Load the data
First, read the csv file into r. Be sure to set the quote= “\”” in order to avoid an error with parsing counts in the thousands out as separate columns.
visits<- read.csv(file="Grand_Canyon_Visitation_2016.csv", header=TRUE, sep=",", quote = "\"", row.names=NULL)
Step 3: Format the data
Convert the traffic counts from a factor to a character.
library(dplyr)
visits$TrafficCount<- as.character(visits$TrafficCount)
Then, remove the comma has to be removed so that R will be able to convert it to a numeric variable. If you don’t take out the comma, you will get an…