在上面的代码中,我们使用函数round()用 4 个数据 x1、x2、x3 和 x4 对值进行了四舍五入,并打印了新值。 示例2:四舍五入到某些数字 Python3 # R program to illustrate # round to a certain digit # Create numeric with many digits x2 <- 3.14734343243 # Round to three decimal places round(x2...
在R语言中,我们经常需要对数值进行舍入操作。为了实现这个目标,R语言提供了一个非常有用的函数,即round()函数。round()函数可以帮助我们将数值四舍五入到指定的小数位数。 语法 round(x, digits = 0) x:需要进行四舍五入操作的数值。 digits:要保留的小数位数,默认为0,表示保留整数。