Open In App

Rounding up to the Specified Number of Significant Digits in R Programming - signif() Function

Last Updated : 10 Jun, 2020
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report
signif() function in R Language is used to round to the specified number of significant digits.
Syntax: signif(x, digits) Parameters: x: specified number digits: significant digits
Example 1: Python3
# R program to illustrate
# signif function

# Generating random number
x <- rnorm(1)
x

# Calling the signif() function
signif(x)
Output:
[1] 1.064923
[1] 1.06492
Example 2: Python3
# R program to illustrate
# signif function

# Generating random number
x <- rnorm(1)
x

# Calling the signif() function
# with 3 significant digits
signif(x, 3)
Output:
[1] 1.078385
[1] 1.08
Note: The rnorm() function generates different random number each time when it runs.

Next Article
Article Tags :

Similar Reads