How present currency value in French format in R

Viewed 125

I have part of code that should show currency value in a French format

This code

library(formattable)

currency(x = 123456, symbol = "€", digits = 0)

gives me "€123,456".

I need code that gives me "123 456€" in a French format for one single value.

Thanks!

1 Answers

I'm not sure how to do it with currency function. It seems to not take in consideration putting the symbol after.

You can maybe use prettyNum function from base R in combination with paste to add the symbol at the end:

paste(prettyNum(x, big.mark = " ",big.interval = 3), "€")

[1] "123 456 €"

Alternatively, in DT, you can use formatCurrency function:

library(DT)

x = 123456
datatable(as.matrix(x)) %>% formatCurrency(1, '\U20AC', digits = 0, before = FALSE, mark = "")

Does it answer your question ?

Related