Homework 2

Justin Norman
DSO545
May 31,2015


Question 1: Read the first chapter (page 11-46) from Visual Revelations by Howard Wainer. Summarize the rules in your own words for creating bad graphics (Use bullet points).

Question 2: The following graphic shows the annual cost per Capita for care of Insane in Pittsburgh City Homes and Pennsylvania State Hospitals.

a. Explain which rule(s) of showing bad graphics has been used to create the above graph.

b. Suggest another way of showing the data in this graph and create it using what we learned in class so far (ggplot2).

Since we’re not working with time-series data…A souped up bar chart should do the trick.


library(ggplot2)
library(gcookbook)
library(gridExtra)
## Loading required package: grid
printCurrency <- function(value, currency.sym="$", digits=0, sep=",", decimal=".") {
  paste(
        currency.sym,
        formatC(value, format = "f", big.mark = sep, digits=digits, decimal.mark=decimal),
        sep=""
  )
}
ggplot(data, aes(x = reorder(City, Population..2013.), y= CPC, fill = Type)) + geom_bar(stat = "identity") + xlab("\nLocation (Smallest to Largest Population)") +   ylab("CPC") + ggtitle("Cost per Capita for Care of the Insane in PA\n") + theme(plot.title = element_text(lineheight=.8, face="bold"))  + scale_fill_manual(values=c("#33a02c","#b2df8a","#1f78b4","#a6cee3"), name="Population Size",breaks=c("Region (N/A)","Small City (<10,000)","Medium City (10,000-50,000)","Large City (50,000+)")) + geom_text(aes(label = printCurrency(CPC)), vjust = 0)