knitr::opts_chunk$set(echo = TRUE, comment = NA) options(width = 120) library(biomod2) library(kableExtra)
hasBmFiles = !is.na(bm.files) hasBmMod = !is.na(bm.mod) hasBmEns = !is.na(bm.ens) hasBmForm = !is.na(bm.form) ind.mod = ind.ens = ind.proj = NA color1 = params.color$color1 color2 = params.color$color2 color3 = params.color$color3
# ind.mod = which(bm.files$file == sub("[.]/", "", bm.mod@link)) ind.mod = which(bm.files$file == sub(paste0(".*", sp.name, "/"), paste0(sp.name, "/"), bm.mod@link)) ind.proj = which(bm.files$type == "projection" & bm.files$refer_to == bm.files$refer_to[ind.mod]) name.proj = unique(bm.files$ID[ind.proj]) ind.ens = which(bm.files$type == "models" & bm.files$level == "ensemble" & bm.files$refer_to == bm.files$refer_to[ind.mod])
fun_call <- function(myCall, myName, ntab = 4) { mess = deparse(myCall) mess = paste0(mess, collapse = "") mess = gsub(" ", "", mess) mess = gsub(", ", "\n, ", mess) mess = gsub("\n, \"", ", \"", mess) mess = paste0(myName, " <- ", mess) mess = gsub("\n,", paste0("\n", paste0(rep("\t", ntab), collapse = "")), mess) return(mess) }
tab = knitr::kable(bm.files[, c("file", "path", "type", "level", "ID")], format = "html") tab = kable_styling(tab, bootstrap_options = "condensed") if (any(!is.na(c(ind.mod, ind.ens)))) { row_spec(tab, c(ind.mod, ind.ens), bold = TRUE, color = color1) }
cat(fun_call(bm.form@call, "myBiomodData", 10))
cat(fun_call(bm.mod@call, "myBiomodModelOut", 10))
cat(fun_call(bm.ens@call, "myBiomodEM", 10))
tab = knitr::kable(bm.files[, c("file", "path", "type", "level", "ID")], format = "html") tab = kable_styling(tab, bootstrap_options = "condensed") if (any(!is.na(ind.proj))) { row_spec(tab, ind.proj, bold = TRUE, color = color3) }
for (proj.i in name.proj) { ind.proj.i = intersect(ind.proj, which(bm.files$ID == proj.i)) for (j in ind.proj.i) { bm.proj = get(load(file = bm.files$file[j])) if (inherits(try(bm.proj@data.type), "try-error")) { bm.proj@data.type <- "binary" } cat(fun_call(bm.proj@call, "myBiomodProj", 10)) cat("\n\n") } } rm(list = basename(bm.files$file))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.