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

Example 2: Round Up to Next 100

round_any(my_values, 100, f = ceiling)    # Rounding to nearest 100
# 100 100 100

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Menu
Top