Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201977

How to make a faceted waffle chart, filling each bin from top left

$
0
0

I'm trying to create a 3x4 grid of bins with a count of observations from my data in each bin. I'm halfway there:

library(ggplot2)
type <- c('daily', 'daily', 'habit', 'habit', 'habit', 'seasonal', 'seasonal', 'year-long', 'year-long', 'year-long', 'year-long', 'year-long')
status <- c('complete', 'incomplete', 'push', 'push', 'incomplete', 'complete', 'complete', 'complete', 'complete', 'push', 'push', 'incomplete')
results <- data.frame(type, status)

ggplot(results) +
  geom_dotplot(aes(x=status, y=type), binwidth=.2) +
  facet_grid(vars(type))

result

Clearly the y-axis is meaningless right now - I'm not sure if geom_dotplot is the right thing to use. I can get similar results with geom_histogram or geom_bar as well.

I'd like dots to start in the upper left corner of each bin. Is this possible? I've tried to use the wafflepackage but can't figure it out. Ideally each dot will be a square, which isn't possible using geom_dotplot, so I'd prefer to use waffle if I can.


Viewing all articles
Browse latest Browse all 201977

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>