Round a number · #7

This snippet needs the following libraries: base · How to load the right library →

To round any numerical value, use round().


Dive deeper

You can use variables providing they're of type numeric:

x <- 54.87


You can specify how many decimals you want with digits. If digits is not specified, round() will default to 0 decimal.

round(54.87, digits = 1)


R: Rounding of Numbers

Access ready-to-use R code snippets

Unlock now