Here we aim to compare the distribution of 5 forest types (including rain forest and tall Eucalyptus forest) across a moisture availability gradient. Moisture availability is defined as rainfall minus potential evaporation. A water balance grid was produced, and the raster library was used to extract values for polygons of the various vegetation types.
The following section just sets up Knitr to upload image to Imgur.com, rather than keep them as Base64 encoded data.
opts_knit$set(upload.fun = imgur_upload) # upload all images to imgur.com
First we load in the data.
root_dir = "/Users/grant/Dropbox/Giants/rwork/"
t.RF = read.csv(paste(root_dir, "tas_raf.csv", sep = ""))
t.RG = read.csv(paste(root_dir, "tas_reg.csv", sep = ""))
q.RF = read.csv(paste(root_dir, "qld_rf.csv", sep = ""))
q.GR = read.csv(paste(root_dir, "qld_gr.csv", sep = ""))
w.KA = read.csv(paste(root_dir, "wa_kar.csv", sep = ""))
Then we need to exclude some data from the raster extraction - some coastal areas with missing/negative data were encounterd, as were multiple tiny polygons that sampled the same water balanced cell, biasing the data with repeated values. So negative, and repeated values need to be removed.
t.RF = subset(t.RF, GRID_CODE > 0)
t.RF = subset(t.RF, !duplicated(t.RF$GRID_CODE))
t.RG = subset(t.RG, GRID_CODE > 0)
t.RG = subset(t.RG, !duplicated(t.RG$GRID_CODE))
q.RF = subset(q.RF, GRID_CODE > 0)
q.RF = subset(q.RF, !duplicated(q.RF$POINTID))
q.GR = subset(q.GR, GRID_CODE > 0)
q.GR = subset(q.GR, !duplicated(q.GR$POINTID))
w.KA = subset(w.KA, GRID_CODE > 0)
w.KA = subset(w.KA, !duplicated(w.KA$POINTID))
Now just to set up each data frame with appropriate row labels, bind them all into a single data frame, and make sure the locations are arranged in a sensible order.
t.RF$Location = "Tas RF"
t.RG$Location = "Tas Tall"
q.RF$Location = "QLD RF"
q.GR$Location = "QLD Tall"
w.KA$Location = "WA Tall"
frm = rbind(t.RF, t.RG, q.RF, q.GR, w.KA)
levels(frm$Location) = c("Tas Tall", "Tas RF", "QLD Tall", "QLD RF", "WA Tall")
And now for the plot.
par(mai = c(1, 1, 0.3, 0.3))
boxplot(GRID_CODE ~ Location, data = frm, horizontal = T)