#' Corrects a number to be in a given interval
#' @param x Number to be corrected
#' @param min Lower bound of the interval. If x is lower than min, the function will return min.
#' @param max Upper bound of the interval. If x is higher than max, the function will return max.
#' @return min, x or max depending on whether x was below, between or above both min and max
fit_into_interval <- function(x, min=0, max=255) {
if(x < min) {
return(min)
} else if(x>max) {
return(max)
} else {
return(x)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.