How to make a waffle chart in R

Chart is based on excellent tutorial by @jayjacobs. Just go to his blog entry at rud.is.

Chart is an attempt to pick a mining capital of the world. It counts all the publicly-listed and active mining companies that are headquartered in each city. Data is from Mining Intelligence.

Here is the code.

library(waffle)  ###Open Waffle package

addresses <- c(`Vancouver, Canada - 805`=805, `Toronto, Canada - 300`=300, `Perth, Australia - 263`=263, 'Sydney, Australia - 96'=96,`London, United Kingdom - 92`=92, `Calgary, Canada - 56`=56,`Melbourne, Australia - 37`=37, `Montreal, Canada - 30`=30,`Johannesburg, South Africa - 14`=14) ###Assign cities and values to variable addresses

waffle(addresses, rows=25, size=0.5, ###rows is rows. size is area around box.

colors=c('#a6cee3','#1f78b4','#b2df8a','#33a02c','#fb9a99','#e31a1c','#fdbf6f','#ff7f00','#cab2d6'), ### using colorbrewer for pretty shades

title="Listed miners and juniors per city", ###Label
       xlab=NULL)

My Github for this project is here.

The original posting is here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s