From 427d700108f0d4be457ffa2b419e299316111227 Mon Sep 17 00:00:00 2001 From: Georges Kunstler <Georges.Kunstler@gmail.com> Date: Tue, 3 Sep 2013 17:00:47 +1000 Subject: [PATCH] solved issue with test in traits data --- R/FUN.TRY.R | 8 +++++--- R/format.function.R | 2 +- merge.data.US.R | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/R/FUN.TRY.R b/R/FUN.TRY.R index 2252d66..ad13607 100644 --- a/R/FUN.TRY.R +++ b/R/FUN.TRY.R @@ -1,4 +1,4 @@ -############################################ 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) } + diff --git a/R/format.function.R b/R/format.function.R index 6b7fa86..2840c0e 100644 --- a/R/format.function.R +++ b/R/format.function.R @@ -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) diff --git a/merge.data.US.R b/merge.data.US.R index 399f931..cff4dce 100644 --- a/merge.data.US.R +++ b/merge.data.US.R @@ -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)) -- GitLab