|
在显示数据的时候,尤其是文章中,需要数字每隔三位就分开,R语言当然能办到。
> a=123456567677
> b=prettyNum(a,big.mark = ",")
> b
[1] "123,456,567,677"
>
如果多个元素会因为对齐位数,出现空格补位情况,可以用正则替换掉空格
> a=c(1233,123,45667,111111)
> b=prettyNum(a,big.mark = ",")
> b
[1] " 1,233" " 123" " 45,667" "111,111"
> c=gsub(" ","",b)
> c
[1] "1,233" "123" "45,667" "111,111"
>
|
|