How to Round Up to Closest 10 (and 100) in R Programming Language (2 Examples)
In this tutorial, I’ll illustrate how to round up to the nearest 10 or 100 in R programming.
Setting up the Examples
my_values <- c(5, 11, 88) |
my_values <- c(5, 11, 88)
install.packages("dplyr") # Install & load dplyr library("dplyr") |
install.packages("dplyr") # Install & load dplyr library("dplyr")
Example 1: Round Up to Next 10
round_any(my_values, 10, f = ceiling) # Rounding to nearest 10 # 10 20 90 |
round_any(my_values, 10, f = ceiling) # Rounding to nearest 10 # 10 20 90
Example 2: Round Up to Next 100
round_any(my_values, 100, f = ceiling) # Rounding to nearest 100 # 100 100 100 |
round_any(my_values, 100, f = ceiling) # Rounding to nearest 100 # 100 100 100