lmer.nolog.output.R 1.35 KB
Newer Older
Georges Kunstler's avatar
Georges Kunstler committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env Rscript

source("R/analysis/lmer.nolog.output-fun.R")
source("R/analysis/lmer.nolog.run.R")

## TODO NEED TO CHANGE THAT TO LOOP OVER FILES AND NOT SCAN ALL FILES
sets <-  c('BCI','Canada','France','Fushan','NVS','Paracou',
           'Spain','US','Swiss','Sweden','NSW','Mbaiki','Luquillo','Japan')
traits <- c("SLA", "Wood.density","Max.height","Leaf.N","Seed.mass")
type.filling <- 'species'
files <-  c()
for (set in sets){
ecoregions <- get.ecoregions.for.set(set)
    for (ecoregion in ecoregions){
      for (trait in traits){
          for (model in c(model.files.lmer.Tf.1,model.files.lmer.Tf.2)){
       source(model, local = TRUE)
       model.obj <- load.model()

       pathout <- output.dir.lmer(model=model.obj$name, trait, set, ecoregion,type.filling)
       files <- c(files,file.path(pathout,"results.no.std.nolog.rds"))
          }
      }
    }
}


out <- lapply(files, summarise.lmer.output.list)
names(out) <- lapply(lapply(files,files.details),function(x) paste(as.vector(x[-6]),collapse="_"))
saveRDS(out,file='output/lmer.list.out.rds')
names.param <- unique(unlist(lapply(out,function(list.res) names(list.res$lmer.summary$fixed.coeff.E))))
DF.results <- do.call("rbind",lapply(out,fun.format.in.data.frame,names.param=names.param))
DF.results$id <- paste(DF.results$set,DF.results$ecocode,sep=".")
saveRDS(DF.results,file='output/lmer.DF.rds')