将数字舍入到前 3 位(以数字 != 0 开头) [英] round number to the first 3 digits (start with digit != 0)
本文介绍了将数字舍入到前 3 位(以数字 != 0 开头)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有预定义的格式函数可以将数字四舍五入到前 3 位数字?(开头应该是数字!= 0)
is there a predefined format-function that rounds a number to the first 3 digits? (The start should be a numbers != 0)
-0.02528498 to -0.0253
1.857403 to 1.86
2060943 to 2060000
0.00006513832 to 0.0000651
推荐答案
可以使用signif
函数:
signif(-0.02528498, 3)
# [1] -0.0253
signif(1.857403, 3)
# [1] 1.86
signif(2060943, 3)
# [1] 2060000
signif(0.00006513832, 3)
# [1] 0.0000651
这篇关于将数字舍入到前 3 位(以数字 != 0 开头)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文