Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Convert Numeric Data into Currency in R?

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

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?

Thanks in advance.

like image 738
cavaunpeu Avatar asked Apr 14 '14 16:04

cavaunpeu


1 Answers

paste('$',formatC(df$Value, big.mark=',', format = 'f'))
like image 138
TheComeOnMan Avatar answered Oct 20 '22 00:10

TheComeOnMan