如何将数字数据转换为R中的货币? [英] How to Convert Numeric Data into Currency in R?
本文介绍了如何将数字数据转换为R中的货币?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
搜索了Google和SO,但找不到合适的答案.我有下表:
Searched Google and SO and couldn't find a good answer. I have the following table:
Country Value
23 Bolivia 2575.684
71 Guyana 3584.693
125 Paraguay 3878.150
49 Ecuador 5647.638
126 Peru 6825.461
38 Colombia 7752.168
151 Suriname 9376.495
25 Brazil 11346.796
7 Argentina 11610.220
171 Venezuela 12766.725
168 Uruguay 14702.505
37 Chile 15363.098
所有值均以美元为单位-我想添加美元符号和逗号.因此,玻利维亚的价值应为$ 2,575.684.另外,是否真的需要将行名更改为1到12?如果是这样,那么简单的方法呢?
All values are in US dollars - I'd like to add in the dollar signs and the commas. Bolivia's value should therefore read $2,575.684. Also, is there any real need to change row names to 1 through 12? If so, an easy way to do so?
谢谢.
推荐答案
paste('$',formatC(df$Value, big.mark=',', format = 'f'))
这篇关于如何将数字数据转换为R中的货币?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文