#' Calculate cull.
#'
#' @param age stand total age
#' @param SppId Id of a species or forest unit
#' @return cull
#' @export
calc_cull <- function(age, SppId) {
# #check is species code exists
# if (!(SppId %in% MISTR_coef$species_model_selection$SppId)) {stop(paste0("Wrong species code: ",SppId))}
#
# #get species code based on species_model_selection table
# SppId <- toupper(SppId)
# current_coefs <- MISTR_coef$species_model_selection[MISTR_coef$species_model_selection$SppId == SppId,]
current_coefs <- MISTR:::check_Spp_get_coefs(SppId = SppId)
SppID_cull <- current_coefs$CullId
coeffs = MISTR_coef$cull_coef
if (!(SppID_cull %in% coeffs$SppId)) {stop(paste0("No formula for ",SppID_cull))}
current_coefs <- coeffs[coeffs$SppId == SppID_cull ,]
(1 - exp(-current_coefs$K1 * age))^ current_coefs$K2
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.