Figure A2-5: Boxplots

Portfolio Categories: All Graphics and SGR Book Graphics.

A Boxplot with Jittered Points

A Boxplot with Jittered Points


# AII.4  - Hypothesis testing ============================================ AII.4

# Using edata--environmental data

edata = read.delim("http://www.kktg.net/R/Appendix2Data.txt",
  colClasses =                         # Set column storage modes
    c("character", rep(NA, 8)),        #   1st col char, let R choose rest 
  header = TRUE,                       # Use column headers for variable names
  row.names = 1)                       # Use first column for obs names
edata$Kyoto = as.logical(edata$Kyoto)  # Make signatory status logical obj

# Drop outliers
edata2 = edata[which(abs(edata$dCO2) < 2.5),]

# Do boxplot

png(filename = "illustrations/fig-AII-5-boxplot.png",
  units = "in",                        # Set measurements in inches
  res = 1200,                          # Set resolution at 1200dpi
  width = 6,                           # Width at 6 inches
  height = 4)                          # Height at 4 inches

par(mai = c(.5, .5, .25, .25))         # Set margins

boxplot(EG ~ Kyoto, data = edata2)     # Produce boxplot
points(1 + jitter(as.integer(edata2$Kyoto)), edata2$EG)

dev.off()                              # Output png file