View source: R/format_expenditure.R
format_expenditure | R Documentation |
Formats a number as an expenditure, e.g. in £m, £k, $m etc. By default, expenditures are rounded to one decimal place in pound sterling, with values below 1 million formatted as £k, and above formatted as £m. This can be overridden by setting the format argument.
format_expenditure(value, format = NULL, currency = "£", dp = 1)
value |
A number representing an amount of money. |
format |
Specify as 'm' or 'k' to force the output in millions or thousands, respectively. |
currency |
A string representing a currency symbol. '£' by default. |
dp |
A number of decimal places to round expenditures to. By default, set to 1 decimal place. |
A character object representing an expenditure.
format_expenditure(36573436) # returns "£36.6m"
format_expenditure(356274) # returns "£356.3k"
format_expenditure(356274, format = "m") # returns "£0.4m"
format_expenditure(3562744, currency = "$") # returns "$3.6m"
format_expenditure(4654262.65, currency = "£", dp = 3) #returns "£4.654m"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.