2

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!

Andrii
  • 2,843
  • 27
  • 33

1 Answers1

1

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 ?

dc37
  • 15,840
  • 4
  • 15
  • 32
  • 1
    I had before the same kind of code for DT. But for one single value, it was a problem to fix it. Thanks!!! – Andrii Apr 03 '20 at 04:14
  • 1
    I see ;) it tooks me a little bit of time to figure it how to convert your single value in the right format to be use in `DT` ;) – dc37 Apr 03 '20 at 04:15
  • 1
    Now my French friends will be happy :) Thanks! – Andrii Apr 03 '20 at 04:19