cummax() function in R Language is used to calculate the cumulative maxima of the values of vector passed as arguments.
Syntax: cummax(x)
Parameters:
x: numeric object
Example 1:
# R program to cumulative maxima # Calling cummax() function cummax(6:2) cummax(-2:-6) cummax(3.8:1.2) |
chevron_right
filter_none
Output:
[1] 6 6 6 6 6 [1] -2 -2 -2 -2 -2 [1] 3.8 3.8 3.8
Example 2:
# R program to cumulative maxima # Creating vectors x1 <- c(5, 3, 2, 6, 3, 4) x2 <- c(-4, 6, 3) # Calling cummax() function cummax(x1) cummax(x2) |
chevron_right
filter_none
Output:
[1] 5 5 5 6 6 6 [1] -4 6 6
Since, the maxima is calculated for the values in decreasing order and hence the above code shows two cumulative values for vectors.
Recommended Posts:
- Calculate the Cumulative Minima of a Vector in R Programming - cummin() Function
- Calculate Cumulative Product of a Numeric Object in R Programming – cumprod() Function
- Calculate Cumulative Sum of a Numeric Object in R Programming - cumsum() Function
- Compute the Parallel Minima and Maxima between Vectors in R Programming - pmin() and pmax() Functions
- Compute the Value of Empirical Cumulative Distribution Function in R Programming - ecdf() Function
- Compute the value of F Cumulative Distribution Function in R Programming - pf() Function
- Perform the Probability Cumulative Density Analysis on t-Distribution in R Programming - pt() Function
- Perform the Inverse Probability Cumulative Density Analysis on t-Distribution in R Programming - qt() Function
- Compute Cumulative Chi Square Density in R Programming - pchisq() Function
- Compute Cumulative Cauchy Density in R Programming - pcauchy() Function
- Compute Cumulative Logistic Density in R Programming - plogis() Function
- Compute Cumulative Log Normal Probability Density in R Programming - plnorm() Function
- Compute the Negative Binomial Cumulative Density in R Programming - pnbinom() Function
- Compute the Cumulative Poisson Density in R Programming - ppois() Function
- Compute the Value of Cumulative Weibull Density in R Programming - pweibull() Function
- Convert an Object into a Vector in R Programming - as.vector() Function
- Check for the Existence of a Vector Object in R Programming - is.vector() Function
- Create a Vector of Colors from a Vector of Gray Levels in R Programming - gray() or grey() Function
- Calculate the difference between Consecutive pair of Elements of a Vector in R Programming - diff() Function
- Calculate Median of elements of a Vector in R Programming - median() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

