Commit 427d7001 authored by Georges Kunstler's avatar Georges Kunstler
Browse files

solved issue with test in traits data

No related merge requests found
Showing with 9 additions and 5 deletions
+9 -5
############################################ FUNCTION TO EXTRACT DECTED OUTLIER AND FORMAT TRY DATA Georges Kunstler
################# FUNCTION TO EXTRACT DECTED OUTLIER AND FORMAT TRY DATA Georges Kunstler
############################################ 14/06/2013
library(MASS)
......@@ -258,8 +258,9 @@ fun.extract.format.sp.traits.TRY <- function(sp, sp.syno.table, data) {
extract.species.try <- fun.turn.list.in.DF(sp, res.list)
##### TODO ADD A TEST OF GOOD EXTRACTION OF TRAITS
test.num <- sample(1:length(sp),1)
if( extract.species.try[test.num,"SLA.mean"] != fun.species.traits(sp[test.num], species.table = sp.syno.table,
test.num <- sample((1:length(sp))[!is.na(extract.species.try[["SLA.mean"]])],1)
if( extract.species.try[test.num,"SLA.mean"] != fun.species.traits(sp[test.num], species.table = sp.syno.table,
traits = traits, data = data)$mean[grep("SLA",traits)]) stop('traits value not good for the species in extraction from TRY')
############### add mean sd of species or genus if we want to use that
sd.vec.sp <- readRDS(file = "./data/process/sd.vec.sp.rds")
......@@ -286,3 +287,4 @@ fun.extract.format.sp.traits.TRY <- function(sp, sp.syno.table, data) {
return(data.frame.TRY)
}
......@@ -302,7 +302,7 @@ if(sum(!data.BA.sp[["obs.id"]] == data[["obs.id"]]) >0) stop("competition index
if(is.data.frame(data.TRY)){
sp.extract <- species.lookup[species.lookup[["sp"]] %in% unique(data[["sp"]]),]
data.traits <- fun.extract.format.sp.traits.TRY(sp=sp.extract[["sp"]],sp.syno.table=sp.extract,data.TRY)
### TO DO ADD OPTION TO INCLUE OTHER DATA on MAX HEIGHT
### TODO ADD OPTION TO INCLUE OTHER DATA on MAX HEIGHT
## save everything as a list
print(dim(data.traits))
list.temp <- list(data.tree=data,data.BA.SP=data.BA.sp,data.traits=data.traits)
......
......@@ -104,6 +104,8 @@ ecoregion.unique <- unique(data.tree[["ecocode"]])
#### lapply function
system.time(lapply(ecoregion.unique[3], FUN = fun.data.per.ecoregion, data.tot = data.tree,
system.time(lapply(ecoregion.unique, FUN = fun.data.per.ecoregion, data.tot = data.tree,
plot.name = "subplot", weight.full.plot = NA, name.country = "US", data.TRY = TRY.DATA.FORMATED,
species.lookup = species.clean))
Supports Markdown
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