Trusted answers to developer questions

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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 syntax for the cummax() function

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))

Implementing the cummax() function

- Line 2: We implement the
`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. - Line 3: We implement the
`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. - Line 4: We implement the
`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.

- Line 5: We implement the
`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.

RELATED TAGS

function

r

communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Keep Exploring

Related Courses