Tutorial: How to make NYT-style bar charts with R
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
New York Times columnist Charles Blow needed a chart to accompany his op-ed piece Lincoln, Liberty and Two Americas (about one-party control in state legislatures). So he turned to resident graphic editor Kevin Quealy, who found the source data and used R to create the chart below:
If you'd like to create similar charts yourself, Kevin provides a useful tutorial on his behind-the-scenes blog, chartsnthings. It's just a few lines of base graphics in R, beginning with line plots and then moving on to bar plots. The abline function is used to create the gridlines. You can also use the same technique to create “waffle charts” (the display technique often used by the NYT, where small blocks represent data elements). You can find the full tutorial at the link below.
chartsnthings: R tutorial: Simple charts
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.