# Rounding off a value to specific digits in R Programming – round() Function

Last Updated : 01 Jun, 2020

R Language provides an inbuilt function `round()` which rounds off to the given number of digits, if no number of digits is provided for round off, it rounds off the number to the nearest integer.

Syntax: round(x, digits=n)

Parameter:
x: Number to be rounded off
digit: Specified digits

Example 1:

 `# R program to calculate round value  ` `   `  `# Using round() method  ` `answer1 <``-` `round``(``2.356``)  ` `answer2 <``-` `round``(``2.356``, digits ``=` `2``)   ` `answer3 <``-` `round``(``2.5``) ` `answer4 <``-` `round``(``2.5``, digits ``=` `1``)   ` ` `  `print``(answer1)  ` `print``(answer2)  ` `print``(answer3)  ` `print``(answer4)  `

Output:

```2
2.36
2
2.5
```

Example 2:

 `# R program to calculate round value  ` `   `  `# Using round() method  ` `answer1 <``-` `round``(c(``1.5``, ``2.6``, ``-``3``, ``-``3.4``))  ` ` `  `print``(answer1)   `

Output:

```2  3 -3 -3
```

Previous
Next