GISSM_germination_wait_times | R Documentation |
Determine wait times until germination based on information on favorable conditions and time required to germinate
GISSM_germination_wait_times(time_to_germinate, duration_fave_cond)
time_to_germinate |
Numerical vector. Elements represent calendar days and values represent number of days required to germination if started on that day. |
duration_fave_cond |
Numerical vector. Elements represent calendar days and values represent number of days with favorable conditions for germination. |
The Rcpp version of the function is about 270x faster for vectors of length 365 and 12,000x faster for vectors of length 11,000 than the R version. The Rcpp version also reduced the memory footprint by a factor of >> 3080.
Schlaepfer, D.R., Lauenroth, W.K. & Bradford, J.B. (2014). Modeling regeneration responses of big sagebrush (Artemisia tridentata) to abiotic conditions. Ecol Model, 286, 66-77.
# The \pkg{Rcpp} function is equivalent to the following R version
germination_wait_times_R <- function(time_to_germinate, duration_fave_cond) {
N <- length(time_to_germinate)
stats::na.exclude(unlist(lapply(seq_len(N), function(t) {
if (is.finite(time_to_germinate[t])) {
t1 <- duration_fave_cond[t:N]
t2 <- stats::na.exclude(t1)
t3 <- which(t2[time_to_germinate[t]] == t1)[1]
sum(is.na(t1[1:t3]))
} else {
NA
}
})))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.