Commit 40271ad6 authored by ghislainv's avatar ghislainv
Browse files

Pheno + WSG MBaiki

parent 92b3ce98
......@@ -17,6 +17,8 @@
# data-base for Mbaiki species
# 3. "DensiteBoisSimpleMbaiki.csv" --> An additional file for wood density data
# 4. "Autour-de-Mbaiki-Releves-par-trait-et-taxon.txt" --> PlanTrait data
# 5. "getpheno_cofortraits_20140212.csv" --> Phenology
# 6. "GlobalWoodDensityDatabase.txt" --> Dryad wood density database
library(reshape)
......@@ -139,17 +141,92 @@ countsup.LeafN # 34
countsup.SLA # 34
countsup.WSG # 0
#=============================================================
# Phenology
d.pheno <- read.csv2(file="data/raw/Mbaiki/getpheno_cofortraits_20140212.csv",header=TRUE)
dim(d.pheno)
names(d.pheno)[8] <- "pheno"
head(d.pheno)
head(data.species.3)
Species.Name.From.List <- function (x) {
genus <- x[1]
sp <- x[2]
lb <- paste(genus,sp,sep=" ")
return(lb)
}
d.pheno$latin.binomial <- c(unlist(lapply(strsplit(as.character(d.pheno$species),split=" "),Species.Name.From.List)))
Unique.Paste <- function (x) {
r <- paste(unique(x),collapse=" ")
return(r)
}
Mat.Pheno <- as.data.frame(tapply(as.character(d.pheno$pheno),d.pheno$latin.binomial,Unique.Paste))
Mat.Pheno$latin.binomial <- row.names(Mat.Pheno)
row.names(Mat.Pheno) <- NULL
names(Mat.Pheno) <- c("D_EV","latin.binomial")
Mat.Pheno$D_EV <- as.character(Mat.Pheno$D_EV)
str(Mat.Pheno)
# Set leaf-exchanger to evergreen
w <- grep("leaf-exchanger",Mat.Pheno$D_EV)
Mat.Pheno$D_EV[w] <- "EV"
Mat.Pheno$D_EV[Mat.Pheno$D_EV=="decidue"] <- "D"
Mat.Pheno$D_EV[Mat.Pheno$D_EV=="sempervirente"] <- "EV"
Mat.Pheno$D_EV[!(Mat.Pheno$D_EV %in% c("D","EV"))] <- NA
# Merge
data.species.4 <- merge(data.species.3,Mat.Pheno,
by.x="Species",by.y="latin.binomial",all.x=TRUE)
#=============================================================
# WSG with Dryad
# Import Dryad
dryad <- read.table(file="data/raw/Mbaiki/GlobalWoodDensityDatabase.txt",header=TRUE,sep="\t")
head(dryad)
names(dryad)
# Mean by species
dryad.2 <- data.frame(Binomial=as.character(levels(as.factor(dryad$Binomial))),
WSG.dryad.mean=NA,WSG.dryad.sd=NA,WSG.dryad.n=NA)
dryad.2$WSG.dryad.mean <- as.numeric(tapply(dryad$WSG,dryad$Binomial,mean))
dryad.2$WSG.dryad.sd <- as.numeric(tapply(dryad$WSG,dryad$Binomial,sd))
dryad.2$WSG.dryad.n <- as.numeric(tapply(dryad$WSG,dryad$Binomial,length))
names(dryad.2)
# Merge
data.species.5 <- merge(data.species.4,dryad.2,by.x="Species",by.y="Binomial",all.x=TRUE)
# Take dryad value if WSG==NA
names(data.species.5)
n.case <- sum(is.na(data.species.5$Wood.density.mean) & !is.na(data.species.5$WSG.dryad.mean))
w <- which(is.na(data.species.5$Wood.density.mean) & !is.na(data.species.5$WSG.dryad.mean))
data.species.5$Wood.density.mean[w] <- data.species.5$WSG.dryad.mean[w]
data.species.5$Wood.density.sd[w] <- data.species.5$WSG.dryad.sd[w]
data.species.5$Wood.density.n[w] <- data.species.5$WSG.dryad.n[w]
# Plots
hist(data.species.5$Wood.density.mean)
hist(data.species.5$SLA.mean)
hist(data.species.5$Leaf.N.mean)
#================
# Output
# Select the right columns
names(data.species.5)
data.species.6 <- data.species.5[,c(1:13,34)]
names(data.species.6)
# Plots
hist(data.species.3$Wood.density.mean)
hist(data.species.3$SLA.mean)
hist(data.species.3$Leaf.N.mean)
hist(data.species.6$Wood.density.mean)
hist(data.species.6$SLA.mean)
hist(data.species.6$Leaf.N.mean)
#================
# Output
# Select the right columns
names(data.species.3)
data.TRAITS.std <- data.species.3[,c(1:13)]
names(data.species.6)
data.TRAITS.std <- data.species.3[,c(1:13,34)]
names(data.TRAITS.std)
data.TRAITS.std$Max.height.mean <- NA
source("R/find.trait/trait-fun.R")
......
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