An error occurred while loading the file. Please try again.
-
Georges Kunstler authoredabe3fcf2
##### FORMAT TRAIT FOR Swiss
source("trait.fun.R")
### read species names
data.tree <- read.csv("../../output/formatted/Swiss/tree.csv", stringsAsFactors = FALSE)
species.clean <- data.frame(sp=data.tree[!duplicated(data.tree[["sp"]]),"sp"],
Latin_name=data.tree[!duplicated(data.tree[["sp"]]),"sp.name"],
Latin_name_syn=data.tree[!duplicated(data.tree[["sp"]]),"sp.name"],
stringsAsFactors =FALSE)
## select column to keep
## read in data
data.TRY.std <- readRDS("../../output/formatted/TRY/data.TRY.std.rds")
max.height <- read.csv(file="../../output/formatted/Swiss/max.height.csv", stringsAsFactors = FALSE)
max.height$sp <- paste("sp",max.height$code,sep=".")
## extract traits and height
data.traits <- fun.extract.format.sp.traits.TRY(sp=species.clean[["sp"]],sp.syno.table=species.clean,data=data.TRY.std)
data.traits <- merge(data.traits,subset(max.height,select=c("sp","Max.height.mean","Max.height.sd")),by="sp",all.x=TRUE,all.y=FALSE)
### TODO ADD GENUS MEAN FOR HEIGHT IF SPECIES IS MISSING
write.csv(data.traits,file="../../output/formatted/Swiss/traits.csv")