The cummax()
function in R obtains the vector's maximum for each index in the vector starting from the beginning of the vector up to the current index.
Here is the syntax of the cummax()
method:
cunmax(x)
The cummax()
function takes a single parameter value, x
, which represents a numerical or integer vector.
This is the code for the cummax()
method:
# implementing the cummax() functioncummax(1:10)cummax(c(1, 3, 4, 5, 3, 2, 5, 1, 7, 8, 8, 6))cummax(c(3, 2, 4, 6, 2, 6, 7, 1, 6, 8, 1, 2))cummax(c(20, 10, 5, 30, 50, 60, 15, 15))
cummax()
to return a vector object where its maximum elements should start with 1
. This is because 1
is the element in the vector object's first index.cummax()
function to return a vector object where its maximum elements should start with 1
. This is because 1
is the element in the vector object's first index.cummax()
function to return a vector object where its maximum elements should start with 3
. This is because 3
is the element in the vector object's first index.cummax()
function to return a vector object where its maximum elements should start with 20
. This is because 20
is the element in the vector object's first index.