Change default number formatting in R -
is there way change default number formatting in r numbers print way without repeatedly having use format() function? example, have
> x <- 100000 > x [1] 100,000
instead of
> x <- 100000 > x [1] 100000
well if want save keystrokes, binding relevant r function pre-defined key-strokes, fast , simple in of popular text editors.
aside that, suppose can write small formatting function wrap expression in; instance:
fnx = function(x){print(formatc(x, format="d", big.mark=","), quote=f)} > 567 * 43245 [1] 24519915 > fnx(567*4325) [1] 2,452,275
r has several utility functions this. prefer "formatc" because it's little more flexible 'format' , 'prettynum'.
in function above, wrapped formatc call in call 'print' in order remove quotes (") output, don't (i prefer @ 100,000 rather "100,000").
Comments
Post a Comment