Dot Plot (Wilkinson Plot)

Want to learn more? I recommend working through: R for Data Science, R Cookbook, and R Graphics Cookbook.

# load the gcookbook package for the data
library(gcookbook)

# load the ggplot2 package
library(ggplot2)

# reset the graphing device
dev.off()
null device
          1
# create a subset of countries
countries2009 <- subset(countries, Year==2009 & healthexp>2000)
# create the ggplot2 data
p <- ggplot(countries2009, aes(x = infmortality))
# create the dotplot layer
p + geom_dotplot(binwidth=.25) +
  # rescale the y axis and remove tic marks
  scale_y_continuous(breaks=NULL) +
  # remove the axis labels
  theme(axis.title.y=element_blank())

png