Matt Dray

# The pinnacle of visualisation

Great news everyone: I’ve taken the best of two stellar data visualisations and smashed them together into something that can only be described as perfection.

Let me set the scene. There’s three things we can agree on:

1. Everyone loves pie charts, particularly when they’re in 3D, exploded and tilted.
2. Word clouds aren’t at all overused.
3. I have too much time on my hands.

With that in mind, I’ve artfully melded clouds and pies into the function cloud_pie, which I think sounds rather sweet.

You can find the function in my personal package dray, which I made following Hilary Parker’s excellent ‘Writing an R Package from Scratch’ blogpost.

devtools::install_github("matt-dray/dray")
library(dray)

# Pie in the sky

cloud_pie depends on the plotrix and wordcloud packages and takes three arguments:

• data: summary dataframe with two columns: categories, and counts for those categories
• name_col: column containing the category names
• count_col: column containing the counts for each category

data must be a dataframe with a column of categories (i.e. name_col) and a column of count values associated with those categories (i.e. count_col).

It’s also completely untested and will probably break if you actually try to use it. So let’s try to use it.

# Pokemon data, of course

Let’s use the same data as in the Pokeballs in Super Smash Bros blog post, which is hosted on GitHub.

library(dplyr)  # pipes and data manipulation

# shape the data
pkmn_summary <- pkmn_raw %>%
group_by(pokemon) %>%
count() %>%
ungroup()

# take a look
dplyr::glimpse(pkmn_summary)
## Observations: 13
## Variables: 2
## $pokemon <fct> beedrill, blastoise, chansey, charizard, clefairy, gol... ##$ n       <int> 26, 25, 26, 23, 18, 26, 25, 24, 20, 3, 25, 26, 23

# Hold on tight

dray::cloud_pie(
)