Reputation: 21
I have imported a dataset which contains a currency but R has converted it to a numeric. The columns is display below:
Tariff
2.9
2.9
1
1.6
It should look like
Price
2.90
2.90
1.00
1.60
If possible if the € symbol was displayed before it, it would be even better. I think digits=2, nsmall=2 would be somewhere near correct.
Upvotes: 2
Views: 3998
Reputation: 51640
You should most probably continue to store the values as numeric, so you can easily perform operations on them.
When you want to display the numbers formatted as currency you can use format
:
> paste(format(tariff, nsmall=2), "€")
[1] "2.90 €" "2.90 €" "1.00 €" "1.60 €"
Upvotes: 2