Figure 2-2: A Default Boxplot

Portfolio Categories: All Graphics and SGR Book Graphics.

fig-2-2-femlife boxplot


myDF = read.delim("http://kktg.net/R/Chapter2Data.txt", 
  header = TRUE,                       # Data has headers for var names
  colClasses = c("character",          # Set storage modes of variables
    "numeric", "numeric", "numeric",   # This is just a convenience and  
    "numeric", "factor", "numeric"))   #   could be adjusted afterwards

                                       #  the same female life expectancy

# A simple boxplot -------------------------------------------------------------
png(filename = "illustrations/fig-2-2-femlife 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 - no Title, no x label

boxplot(myDF$FemLife ~ myDF$PressFree) # Boxplot: femlife by free press status

dev.off()                              # Output png file