Geoscience Reference
In-Depth Information
quantile.cuts <- function (x, n = 5, params = NA)
{
if (!is.na(n))
probs = (1:(n - 1))/n
if (!is.na(params))
probs = params
quantile(x, probs)
}
choro.legend <- function (px, py, sh, under = “under”, over = “over”,
between = “to”,
fmt = “%g”,…)
{
x = sh$breaks
lx = length(x)
if (lx < 3)
stop(“break vector too short”)
res = character(lx + 1)
res[1] = paste(under, sprintf(fmt, x[1]))
for (i in 1:(lx - 1)) res[i + 1] <- paste(sprintf(fmt, x[i]),
between, sprintf(fmt, x[i + 1]))
res[lx + 1] <- paste(over, sprintf(fmt, x[lx]))
maxwidth <- max(strwidth(res))
temp <- legend(x = px, y = py, legend = rep(“ “, length(res)),
fill = sh$cols, text.width = maxwidth,…)
text(temp$rect$left + temp$rect$w, temp$text$y, res, pos = 2)
}
###################################################
### code chunk number 4: regression
###################################################
## From: Annette Dobson (1990)
## “An Introduction to Generalized Linear Models”.
## Page 9: Plant Weight Data.
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
Group <- gl(2,10,20, labels = c(“Ctl”,”Trt”))
Weight <- c(ctl, trt)
lm.Dobson.p9 <- lm(Weight ~ Group)
anova(lm.Dobson.p9)
###################################################
### code chunk number 5: regression_table
###################################################
tab <- xtable(anova(lm.Dobson.p9),
caption = 'Formatted ANOVA Output',
label = 'anovatab')
print(tab,table.placement = 'h')
###################################################
### code chunk number 6: georgia_map
###################################################
par(mar = c(0.5,0.5,1.5,0.5))
shd <- auto.shading(MedInc/1000,n = 7,
cols = brewer.pal(7,'YlOrBr'))
choropleth(georgia,MedInc/1000,shading = shd)
Search WWH ::




Custom Search