r - change data frame so thousands are separated by dots -
at moment, i'm working rmarkdown , pandoc. data.frames in r this:
3.538e+01 3.542e+01 3.540e+01 9.583e+00 9.406e+00 9.494e+00 2.601e+05 2.712e+05 5.313e+05
after ran pandoc, result looks this:
35.380 35.420 35.400 9.583 9.406 9.494 260116.000 271217.000 531333.000
what should is:
35,380 35,420 35,400 9,583 9,406 9,494 260.116 271.217 531.333
so want commas instead of dots , want no comma or dot after 260116 (thousand numbers). dots separate thousand nice. there way directly change appearance in r or have set options in knitr/markdown?
thanks
here's example of of conversions can done format()
:
x <- c(35.38, 35.42, 35.4, 9.583, 9.406, 9.494, 260100, 271200, 531300) format(x, decimal.mark=",", big.mark=".", scientific=false) # [1] " 35,380" " 35,420" " 35,400" " 9,583" " 9,406" # [6] " 9,494" "260.100,000" "271.200,000" "531.300,000"
there several other options, such trim
, justify
, , on might of interest in getting output ready pandoc.
Comments
Post a Comment