I'm writing a quite large document in Rmarkdown which has financial data in it. I format that data using scales::dollar() currently something like this:
require (scales)
x = 100000
cat (dollar (x, prefix ="?", big.mark=","))
?100,000
But actually, I'd quite like to get ?100k out in that instance so I'd do:
cat (dollar (x/10^3, prefix ="?", suffix="k" ))
?100k
But x could be 100 or 10,000,000. I want some form of 'automatic' version that might give me something like:
require (scales)
y = 0:7
x = 1^y
dollar(x, prefix="?")
[1] "?1" "?10" "?100" "?1,000" "?10,000" "?100,000" "?1,000,000" "?10,000,000"
But what I want is more like:
?1.00 ?10.00 ?100 ?1k ?10k ?100k ?1m ?10m
I'm sure I can write something as a little function, but before I do - is there something already out there?
I have a similar need to format milligrams through to kilograms.
********************************************************************************************************************
This message may contain confidential information. If ...{{dropped:27}}