So I thought I’d have a go as well. I’ve downloaded the incidence data from the Tycho website. http://www.tycho.pitt.edu/l1advanced.php You have to register and stuff. I also deleted the first two rows with titles in.
Before I start, my aims:
No funky colour ramps. Let the data speak for itself.
Distinguish between missing data and zeros.
I’m considering reordering the states. Perhaps largest states at the top? Or high measles burden at top.
The code is available as an Rmarkdown document on github.
So, read in data. Then shamelessly copy code from @biomickwatson to get to a decent starting point.
To go from weekly data to annual, I am taking the mean across the year (with NAs removed). As pointed out by @RobertAllison__, if you sum the data, the NAs introduce a bias. So I am taking the mean, then multiplying back by 52. To get expected cases per 100,000, per year.
OK. NA’s are white. Other colours are ramped. That’s good. The colour ramp here is funny because I’m using @biomickwatson’s values which match the cases data rather than the incidence data.
I like the labels on the right so I’ll leave that.
Now to get some good colours. I might try and leave NA’s white and have a ramp that doesn’t include white. RColorBrewer asseeeeemble.
Also going to change to 2 letter state names. The csv is just a list copied from the web.
As suggested by @bulboussquidge I’ll try just clipping the few high values to a something+ category.
Only 3 data points are affected. I’m torn here.
Now I want to try organising the data by measles burden. The areas with lots of measles are the important bit, so I think that makes sense. I think I’ll just do mean (with NAs removed) and order by size. Certainly a useful thing could be to order by number of cases rather than incidence. But I don’t want to go get the other dataset.
I think the reordering is an improvement. It’s interesting at least.
Finally, I just want to tweak a few things. This turns out to be a complete pain. I had ago hacking heatmap.2(). The new function is saved in customHeatmap.R.
At this point, I’m bored of hacking. I’m just going to make the last few changes in inkscape.