glue icon indicating copy to clipboard operation
glue copied to clipboard

Format helper

Open hadley opened this issue 6 years ago • 0 comments

Something like this:

big_mark <- function(x, digits = 2) {
  x <- round(x, digits)
  mark <- if (identical(getOption("OutDec"), ",")) "." else ","
  format(x, big.mark = mark, scientific = FALSE)
}
big_mark(1234 + 1/3, digits = 2)
big_mark(1234 + 1/3, digits = 0)
big_mark(1234 + 1/3, digits = -1)

hadley avatar Apr 09 '18 17:04 hadley