Search notes:

R function: formatC

nums <- seq( -1, 1, length.out=7)

nums
# [1] -1.0000000 -0.6666667 -0.3333333  0.0000000  0.3333333  0.6666667  1.0000000

formatC( nums )
# [1] "-1"      "-0.6667" "-0.3333" "0"       "0.3333"  "0.6667"  "1"

formatC( nums, digits=2)
# [1] " -1"   "-0.67" "-0.33" "  0"   "0.33"  "0.67"  "  1"

formatC( nums, digits=2, format='f')
# [1] "-1.00" "-0.67" "-0.33" "0.00"  "0.33"  "0.67"  "1.00"
Github repository about-r, path: /functions/formatC.R

See also

Index to (some) R functions

Index