The “cummax” Function in R
Package: Base R (No specific package, it’s a built-in function)
Purpose: To compute the cumulative maximum of a numeric vector.
General Class: Mathematical Computation
Required Argument(s):
x: A numeric vector for which the cumulative maximum is to be computed.
Notable Optional Arguments:
None
Example:
# Example usage
my_vector <- c(2, 3, 1, 4, 5)
cumulative_maximum <- cummax(my_vector)
print(cumulative_maximum)In this example, cummax is a built-in function in base R, and it is used to calculate the cumulative maximum of a numeric vector. The x argument is the only required argument, and it represents the numeric vector for which the cumulative maximum is calculated. There are no notable optional arguments for this function. The result is a numeric vector where each element represents the cumulative maximum up to that point in the input vector.