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" |
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 |
cumsum(table(my_values)) # Applying table() & cumsum() functions # a b c d e # 41 80 120 153 200