1. Estimates with confidence intervals and boxplots
library(micromapST)
data(wflung00and95, wflung00and95US, wflung00cnty)
tmp <- split(wflung00cnty$rate, wflung00cnty$stabr)
wfboxlist = boxplot(tmp, plot = FALSE)
panelDesc <- data.frame(type = c("map", "id", "dotconf", "boxplot"), lab1 = c("",
"", "State Rate", "County Rates"), lab2 = c("", "", "and 95% CI", "(suppressed if 1-9 deaths)"),
lab3 = c("", "", "Deaths per 100,000", "Deaths per 100,000"), col1 = c(NA,
NA, 1, NA), col2 = c(NA, NA, 3, NA), col3 = c(NA, NA, 4, NA), refVals = c(NA,
NA, wflung00and95US[1, 1], NA), refTexts = c(NA, NA, "US Rate 2000-4",
NA), panelData = c("", "", "", "wfboxlist"))
micromapST(wflung00and95, panelDesc, sortVar = 1, ascend = FALSE, title = c("White Female Lung Cancer Mortality, 2000-2004",
"State Rates & County Boxplots"))
2. Showing Map Contours and Change:Arrows and Percent ChangeBars
data(wmlung5070, wmlung5070US)
before <- wmlung5070$RATEWM_50
after <- wmlung5070$RATEWM_70
percentChange <- 100 * (after - before)/before
panelDesc = data.frame(type = c("mapcum", "id", "arrow", "bar"), lab1 = c("",
"", "Rates in", "Percent Change"), lab2 = c("", "", "1950-69 and 1970-94",
"1950-69 To 1970-94"), lab3 = c("", "", "Age-Adjusted Deaths per 100,000",
"Percent"), col1 = c(NA, NA, 1, 5), col2 = c(NA, NA, 3, NA))
micromapST(wmlung5070, panelDesc, sortVar = 1, ascend = FALSE, title = c("Change in White Male Lung Cancer Mortality Rates",
"from 1950-69 to 1970-94"))
3. Time series line plots with bands from interpolating point confidence intervals
data(TSdata)
dimNameList <- dimnames(TSdata)
dimNameList[[2]] <- 1996:2010 # or paste('Y',1996:2010,sep='')
dimNameList[[3]] <- c("Year", "Estimate", "Lower Bnd", "Upper Bnd")
dimnames(TSdata) <- dimNameList
year <- TSdata[1, , 1]
est <- TSdata[1, , 2]
lowerBnd <- TSdata[1, , 3]
upperBnd <- TSdata[1, , 4]
source("gridPlotFunctions.r")
gPlot(range(year), range(lowerBnd, upperBnd), type = "n", main = "Alabama",
ylab = "Female Lung Cancer Age-Adjusted Mortality Rates per 100000", xlab = "Year")
polyX <- c(year, rev(year))
polyY <- c(lowerBnd, rev(upperBnd))
polygon(polyX, polyY, border = rgb(0.8, 0.9, 1, 0.6), col = rgb(0.8, 0.9, 1,
0.6), density = -1)
lines(year, est, type = "o", col = "blue", lwd = 2)
panelDesc = data.frame(type = c("maptail", "id", "tsconf", "dot"), lab1 = c("",
"", "Time Series", "Female"), lab2 = c("", "", "Annual Rate per 100,000",
"Most Recent Rate (2010)"), lab3 = c("", "", "Years", "Deaths per 100,000"),
lab4 = c("", "", "Rate", ""), col1 = c(NA, NA, NA, 15), panelData = c(NA,
NA, "TSdata", NA))
mortalityRates <- data.frame(TSdata[, , 2])
ExTitle <- c("Time Series with Confidence bands", "Annual Female Lung Cancer Mortality Rates, 1996-2010")
micromapST(mortalityRates, panelDesc, sortVar = 15, ascend = FALSE, title = ExTitle)
4. Centered (diverging) stacked bars
data(Educ8thData)
panelDesc = data.frame(type = c("maptail", "id", "dot", "ctrbar"), lab1 = c("",
"", "Avg. Scores", "Math Proficiency"), lab2 = c("", "", "", "<Basic, Basic, Proficient, Advanced"),
lab3 = c("", "", "", "% to Left of 0 | % to Right"), col1 = c(NA,
NA, 3, 4), col2 = c(NA, NA, NA, 7))
ExTitle = c("Stacked Bars: Educational Progress (NAEP) in Math, 2011, 8th Grade",
"Centered at Not Proficient vs. Proficient")
micromapST(Educ8thData, panelDesc, sortVar = 3, title = ExTitle)
5. A redesign using bar plots
df <- Educ8thData
df$atLeastProf <- df$PctProficient + df$PctAdvanced
df$atLeastBasic <- df$PctAtBasic + df$atLeastProf
ord <- order(df$PctAdvanced, df$atLeastProf, df$atLeastBasic, decreasing = TRUE)
df$sortVar <- (nrow(df):1)[order(ord)]
panelDesc = data.frame(type = c("mapcum", "id", "bar", "bar", "bar"), lab1 = c("",
"", "", "At Least", "At Least"), lab2 = c("", "", "Advanced", "Proficient",
"Basic"), lab3 = c("", "", "Percent", "Percent", "Percent"), col1 = c(NA,
NA, 7, 9, 8))
ExTitle = c("Educational Achievement (NAEP) in Math, 2011, 8th Grade", "Percents Rounded to Integers")
micromapST(df, panelDesc, sortVar = 10, ascend = FALSE, title = ExTitle)