Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将R中0位小数的百分比四舍五入_R_Format_Decimal_Rounding_Percentage - Fatal编程技术网

如何将R中0位小数的百分比四舍五入

如何将R中0位小数的百分比四舍五入,r,format,decimal,rounding,percentage,R,Format,Decimal,Rounding,Percentage,寻找像EXCEL“增加小数点”、“减少小数点”这样的简单方法 #示例编号 d使用圆形和粘贴: d <- c(0.6199548,0.8884106,0.9030066) paste0(round(d*100), "%") [1] "62%" "89%" "90%" d我建议您在决定它能做什么和不能做什么之前,先看一下百分比的文档 # library scales result cannot adjust to 0 decimal ## OR CAN IT percent(d, 1) [

寻找像EXCEL“增加小数点”、“减少小数点”这样的简单方法

#示例编号

d使用
圆形
粘贴

d <- c(0.6199548,0.8884106,0.9030066)
paste0(round(d*100), "%")

[1] "62%" "89%" "90%"

d我建议您在决定它能做什么和不能做什么之前,先看一下
百分比的文档

# library scales result cannot adjust to 0 decimal
## OR CAN IT
percent(d, 1)
[1] "62%" "89%" "90%"
从帮助页面
?百分比

percent(x, accuracy = NULL, scale = 100, prefix = "",
  suffix = "%", big.mark = " ", decimal.mark = ".", trim = TRUE,
  ...)
# ...
# accuracy  Number to round to, NULL for automatic guess.

@马吕斯-甚至是
sprintf(“%.0f%%”,d*100)
-如果你想要0个小数,你必须要求它。是的,但在我发布问题之前,我就遇到了这个错误:
percent(d,1)error in percent(d,1):未使用的参数(1)
也许你正在使用另一个包中的
percent
函数?或者您可能有一个旧版本的
标尺
?从套餐新闻看,似乎
准确性
参数是在1.0版中引入的。正如我在回答中所说的,这对我来说很好。谢谢你,格雷戈,我想我应该检查一下天平的版本
percent(x, accuracy = NULL, scale = 100, prefix = "",
  suffix = "%", big.mark = " ", decimal.mark = ".", trim = TRUE,
  ...)
# ...
# accuracy  Number to round to, NULL for automatic guess.