France.R 1.19 KiB
#!/usr/bin/env Rscript
##### FORMAT TRAIT FOR France
source("R/find.trait/trait.fun.R")
source("R/format.data/format.fun.R")
### read species names
species.clean <- (read.csv("data/raw/France/species.csv", stringsAsFactors = FALSE))
species.clean$Latin_name <- (gsub("_", " ", species.clean$Latin_name))
species.clean$Latin_name_syn<- (gsub("_", " ", species.clean$Latin_name_syn))
species.clean <-  subset(species.clean,subset=!is.na(species.clean$Latin_name_syn))
species.clean <-  subset(species.clean,subset=!duplicated(species.clean$Latin_name_syn))
species.clean$sp <- species.clean$code
species.clean$code <- NULL
## read in data
data.TRY.std <- readRDS("output/formatted/TRY/data.TRY.std.rds")
max.height <- read.csv(file="output/formatted/France/max.height.csv", stringsAsFactors = FALSE)
### extract and add 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/France/traits.csv",row.names = FALSE)