July 19, 2018

R Format functions

Format functions in R

format(x, trim = FALSE, digits = NULL, nsmall = 0L, justify = c("left", "right", "centre", "none"), width = NULL, na.encode = TRUE, scientific = NA, big.mark   = "",   big.interval = 3L, small.mark = "", small.interval = 5L, decimal.mark = getOption("OutDec"), zero.print = NULL, drop0trailing = FALSE, …)
format(dates, format="%m,%d,%Y")
format(1:10, trim = TRUE)
format(zz, justify = "left", digits = 3, nsmall = 3)
format(format(x, trim = TRUE), justify = "centre")
format(c(1, NA), na.encode = FALSE)
format(2 ^ 31 - 1, scientific = TRUE)
format(123456789.87654321, digits  = 17, big.mark = ",", small.mark = " ", small.interval = 2)
format(co2, justify = "left", width = 10, scientific = TRUE)
format(1000000000, big.mark = ",", big.interval = 3, scientific = FALSE)

formatC(x, digits = NULL, width = NULL, format = NULL, flag = "", mode = NULL, big.mark = "", big.interval = 3L, small.mark = "", small.interval = 5L, decimal.mark = getOption("OutDec"), preserve.width = "individual", zero.print = NULL, drop0trailing = FALSE)
formatC(xx)
formatC(c("a", "Abc", "no way"), width = -7)
formatC(value, format="f", digits=2) ==> fixed format
formatC(x, format="e") ==> scientific format
formatC(x, format="e", digits = 5)
formatC(x, format="E")
formatC(xx[1:4], format = "f", digits = 75)
formatC(x, format = "f", digits = 8, width = 8)
formatC(x, format = "g", digits = 3)
formatC(x, format = "fg", digits = 2)
formatC(x, format = "d", big.mark = " ", big.interval = 3)
formatC(x, format = "fg", decimal.mark = ",", small.mark = " ", small.interval = 3)

prettyNum(x, big.mark = "",   big.interval = 3L, small.mark  = "", small.interval = 5L, decimal.mark = getOption("OutDec"), input.d.mark = decimal.mark, preserve.width = c("common", "individual", "none"), zero.print = NULL, drop0trailing = FALSE, is.cmplx = NA, …)
prettyNum(r, big.mark = ",")
prettyNum(r, big.mark = "'", decimal.mark = ",")
prettyNum(fv, drop0trailing = TRUE)

.format.zeros(x, zero.print, nx = suppressWarnings(as.numeric(x)))

Related R articles:  Functions in R     R Date Time operations


No comments:

Post a Comment