Create Cumulative Frequency Table in R (Example Code)

In this tutorial, I’ll show how to get the cumulative frequency of a vector in R programming.

Introduction of Example Data

set.seed(928563)                                # Set random seed
my_values <- sample(letters[1:5], 200, TRUE)    # Sample random letters
head(my_values)                                 # Show first values of example vector
# [1] "d" "e" "e" "a" "c" "d"

Example: Create Cumulative Frequency Table in R

cumsum(table(my_values))                        # Applying table() & cumsum() functions
#   a   b   c   d   e 
#  41  80 120 153 200

Leave a Reply

Your email address will not be published.

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed