GISSM_get_KilledBySoilLayers | R Documentation |
Function that checks whether all relevant (those with roots) soil layers are under conditions of mortality (kill.conditions) for each day of a given year
GISSM_get_KilledBySoilLayers(relevantLayers, kill_conditions)
relevantLayers |
An integer vector, usually of length 365 or 366 (days). |
kill_conditions |
A m x p logical matrix with
|
relevantLayers
takes either NA
if no soil layers should be
considered (e.g., because not yet germinated), or an integer number
between 1 and the number of simulated soil layers. The number indicates
the depth to which a seedling has grown roots and over which layers
kill.conditions
will be evaluated.
A logical vector of the length of relevantLayers
with
values containing NA
for days when conditions were not evaluated,
TRUE
if all relevant soil layers (columns) of kill.conditions
were TRUE
, and with FALSE
otherwise
The Rcpp version of the function is about 165x faster than the version previous to commit 6344857a9cdb08acf68fa031c43cf4a596613aad 'Small speed improvements' and about 70x faster than the R version. The Rcpp version also reduced the memory footprint by a factor of 200.
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
get_KilledBySoilLayers_R <- function(relevantLayers, kill.conditions) {
vapply(
seq_along(relevantLayers),
function(k) {
if (all(is.finite(relevantLayers[k]))) {
all(as.logical(kill.conditions[k, seq_len(relevantLayers[k])]))
} else NA
},
FUN.VALUE = NA
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.