scales::comma(c(0L, 1L), accuracy = 1)
## [1] "0" "1"
scales::comma(c(0L, 1L), accuracy = 0.1)
## [1] "0.0" "1.0"
scales::comma(c(0L, 1L), accuracy = 0.01)
## [1] "0.00" "1.00"
scales::comma(c(0L, 1L))
## [1] "0.0" "1.0"
scales::comma(c(0L, 9L))
## [1] "0.0" "9.0"
scales::comma(c(0L, 10L))
## [1] "0" "10"
=> 最も近い2つの値の差が9以下の場合、accuracyが0.1以下になる。 特に、元のベクトルが整数型でも小数点が付く。
https://scales.r-lib.org/reference/number_format.html
accuracy Number to round to. Use (e.g.) 0.01 to show 2 decimal places of precision. If NULL, the default, uses a heuristic that should ensure breaks have the minimum number of digits needed to show the difference between adjacent values.
Applied to rescaled data.