diff --git a/R/FUN.TRY.R b/R/FUN.TRY.R index 2252d66db90d57cc17eddc11529d9c5eabe3b91d..ad136076bcbf7f7e0838864c4d993eb027eb8c06 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 6b7fa86b627b3bfc4827cb11671239fe840cd26f..2840c0e51add7901ea89e8572a672a87f6f6acce 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 399f93134910a9c4b5418899fae602ea125f6bb7..cff4dcef751cbea8cd98c46afafd2b113630dd09 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))