#' Maximum
#'
#' This function takes a single numeric vector and returns the maximum value in the vector.
#'
#' @param x Numeric vector of values
#'
#' @return Maximum value
#' @export
#'
#' @examples
#' x <- 1:10
#' maximum(x)
maximum <- function(x){
check_numeric_vector(x) # Check that the input is a single numeric vector
n <- length(x) # Number of elements in x
x_max <- x[1]
for (i in 2:n){
if (x[i] > x_max){
x_max <- x[i]
}
}
return(x_max)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.