Commit ca493f9f authored by Georges Kunstler's avatar Georges Kunstler
Browse files

minor change to canada

parent f4bf5edf
......@@ -14,6 +14,7 @@ figs
*.docx
*.html
*.Rdata
*.RData
*.rds
*.R~
*.Rout
......
......@@ -1192,13 +1192,11 @@ legend("center",legend = biomes, col = col.vec[biomes], lty =1, lwd = 2,
## get fixed biomes
fun.get.fixed.biomes <- function(var, list,
biomes.vec = c("Boreal forest",
"Subtropical desert",
"Temperate forest",
"Temperate grassland desert",
"Temperate forest",
"Temperate rain forest",
"Tropical forest savanna",
"Tropical rain forest",
"Tundra",
"Woodland shrubland")){
param <- list$lmer.summary$fixed.coeff.E
remaining <- grep(paste0(':',var), names(param))
......@@ -1209,7 +1207,7 @@ ff <- ~ biomes.id
mm <- model.matrix(ff, data.frame(biomes.id = biomes.vec))
# compute mean and std based on Bolker post
param.biomes <- drop(mm %*% param[select])
names(param.biomes) <- sort(unique(data$biomes.id))
names(param.biomes) <- biomes.vec
std.biomes <- sqrt(diag(mm %*% tcrossprod(list$vcov[select, select],mm)))
return(list(fixed.biomes = param.biomes,
fixed.biomes.std = std.biomes))
......@@ -1220,14 +1218,12 @@ return(list(fixed.biomes = param.biomes,
plot.param.biomes.fixed <- function(list.res,
model,
biomes = c("Boreal forest",
"Subtropical desert",
"Temperate forest",
"Temperate grassland desert",
"Temperate forest",
"Temperate rain forest",
"Tropical forest savanna",
"Tropical rain forest",
"Tundra",
"Woodland shrubland") ,
"Woodland shrubland"),
traits = c('Wood.density', 'SLA', 'Max.height'),
param.vec = c("Tf", "sumTnBn",
"sumTfBn", "sumTnTfBn.abs"),
......@@ -1243,7 +1239,7 @@ plot.param.biomes.fixed <- function(list.res,
names.bio,
...){
m <- matrix(c(1:4), 1, 4)
layout(m, widths=c(5.3, 2, 2 ,2.5)/10,
layout(m, widths=c(5.3, 2, 2 ,3.5)/10,
heights=c(4)/10)
for (i in traits){
list.temp <- list.res[[paste0("all.no.log_", i ,
......@@ -1288,7 +1284,7 @@ par(mar=c(0, 0, 0, 0))
plot(1,1,type="n", axes=F, xlab="", ylab="")
legend("center",legend = biomes, col = col.vec[biomes],
pch = pch.vec[biomes], lty =1, lwd = 2,
bty = 'n', cex = 1)
bty = 'n', cex = 2)
}
......
......@@ -245,7 +245,7 @@ plot.param(list.all.results.species.id ,
xlim = c(-0.42, 0.18))
##+ Fig3b, fig.cap='**effect size parameters with no subsampling.**', fig.width=10, fig.height=5, echo = FALSE
plot.param(list.all.results ,
plot.param(list.all.results ,
model = 'lmer.LOGLIN.ER.AD.Tf.fixed.species',
traits = c('Wood.density', 'SLA', 'Max.height'),
param.vec = c("Tf","sumBn", "sumTfBn",
......
......@@ -3,46 +3,69 @@
### MERGE canada DATA
source("R/format.data/format-fun.R")
library(reshape, quietly = TRUE)
library(dplyr)
dir.create("output/formatted/Canada", recursive = TRUE, showWarnings = FALSE)
######################### READ DATA read individuals tree data
data.canada <- read.csv("data/raw/Canada/Canada_Data2George_20130910.csv",
header = TRUE, stringsAsFactors = FALSE)
data.canada <- select(data.canada, -IN_1410)
data.canada2 <- read.csv("data/raw/Canada/NovaScotia_2George_20131025.csv",
# remaining data
data.canada.NS <- read.csv("data/raw/Canada/NovaScotia_2George_20131025.csv",
header = TRUE, stringsAsFactors = FALSE)
names(data.canada2)[c(2, 6, 8, 9, 12)] <-c("species_FIACode", "SUBPLOT_ID",
"Lat", "Lon", "Ecocode")
data.canada <- rbind(data.canada, data.canada2)
data.canada.NS <- select(data.canada.NS, -IN_1410)
data.canada.NS <- select(data.canada.NS,
species_FIACode = Species_FIAcode,
SUBPLOT_ID = SubPlot_ID,
Lat = Latitude,
Lon = Longitude,
Ecocode = EcoCode,
matches("."))
data.canada.NS <- mutate(data.canada.NS,
Ecocode = as.character(Ecocode))
data.canada.NS <- data.canada.NS[ , names(data.canada)]
## single file
data.canada <- rbind_list(data.canada, data.canada.NS)
#MCV remove plots smaller than 0.02 ha
#(plot size with average of <20 trees 10cm dbh)
#MCV and remove trees <10 cm dbh
data.canada <- subset(data.canada,
subset = (data.canada$SubPlotSize>=0.02 &
data.canada$InitDBH>=10) )
data.canada <- filter(data.canada,
SubPlotSize>=0.02,
InitDBH>=10)
sum(is.na(data.canada$species_FIACode))
data.canada$sp <- data.canada$species_FIACode
data.canada <- select(data.canada,
sp = species_FIACode,
matches("."))
data.canada$sp[data.canada$sp==8349] <- 762
#MCV replace incorrect sp code for Prunus serotina
data.canada$species_FIACode <- NULL
#MCV replace incorrect sp code for Prunus serotina
### read species names and merge with data.canada
species.clean <- read.csv("data/raw/Canada/FIA_REF_SPECIES.csv",
stringsAsFactors = FALSE)
species.clean$Latin_name <- paste(species.clean$GENUS,
species.clean$SPECIES, sep = " ")
species.clean$Latin_name_syn<- paste(species.clean$GENUS,
species.clean$SPECIES, sep = " ")
data.canada <- merge(data.canada, data.frame(sp = species.clean$SPCD,
Latin_name = species.clean[, "Latin_name"],
stringsAsFactors = F),
by = "sp", all.x = T)
data.canada$sp <- paste("sp", data.canada$sp, sep = ".")
data.canada$sp.name <- data.canada$Latin_name; data.canada$Latin_name<- NULL
data.canada$sp.name[is.na(data.canada$sp.name)] <- data.canada$sp[is.na(data.canada$sp.name)]
species.clean <- mutate(species.clean,
Latin_name = paste(GENUS,
SPECIES, sep = " "))
species.clean <- mutate(species.clean,
Latin_name_syn = paste(GENUS,
SPECIES, sep = " "))
data.canada <- left_join(data.canada,
data.frame(sp = species.clean$SPCD,
Latin_name = species.clean[, "Latin_name"],
stringsAsFactors = F),
by = "sp")
data.canada <- mutate(data.canada, sp =paste("sp", sp, sep = "."))
data.canada <- select(data.canada,
sp.name = Latin_name,
matches("."))
data.canada <- mutate(data.canada,
sp.name = ifelse(is.na(sp.name), sp, sp.name))
## MASSAGE TRAIT DATA HEIGHT DATA FOR TREE MISSING BRING US DATA FOR HEIGHT OVER
## WHEN WE ANALYZE THAT DATASET LATER ON
## FORMAT INDIVIDUAL TREE DATA
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment