discrete_mode <- function(x) {
condition <- is.factor(x)
if(condition) {
x_levels <- levels(x)
x_probability <- m_estimator(x)
x_maximum <- which_maximum(x_probability)
x_mode <- factor(x_levels[x_maximum], levels = x_levels)
# return
rout <- x_mode
return(rout)
} else {
stop("x MUST be a factor.")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.