round()

round(x, digits = 0)
Returns: numeric · Updated March 13, 2026 · Base Functions
base math numeric rounding

The round() function rounds numeric values to the specified number of decimal places. It uses round half to even (bankers rounding) by default, which reduces cumulative rounding errors in statistical computations.

Syntax

round(x, digits = 0)

Parameters

ParameterTypeDefaultDescription
xnumericA numeric vector or scalar to round
digitsinteger0Number of decimal places. Negative values round to powers of 10

Examples

Basic rounding

# Round to whole number
round(3.7)
# [1] 4

round(3.3)
# [1] 3

Rounding to decimal places

# Round to 2 decimal places
round(3.14159, 2)
# [1] 3.14

round(2.675, 2)
# [1] 2.67

Rounding to powers of 10

# Round to nearest 10
round(123, digits = -1)
# [1] 120

# Round to nearest 100
round(1234, digits = -2)
# [1] 1200

Working with vectors

x <- c(1.5, 2.5, 3.5, 4.5)
round(x)
# [1] 2 2 4 4

df <- data.frame(value = c(1.234, 5.678, 9.012))
df\ <- round(df\, 2)
df
#   value
# 1  1.23
# 2  5.68
# 3  9.01

Common Patterns

Currency rounding

prices <- c(19.999, 29.999, 14.999)
round(prices, 2)
# [1] 19.99 29.99 14.99

Normalizing measurements

readings <- c(1.23456, 7.89012, 3.45678)
round(readings, 3)
# [1] 1.235 7.890 3.457

See Also