locale | R Documentation |
Localize formatting and symbols
gt()
, some cols_*()
and fmt_*()
functions have a locale
argument.
You can pass locale
as a 2 letters string or 4. (e.g. "fr"
for French,
"pt-BR"
for Brazilian Portuguese). gt also resolves different spellings
internally as much as possible. For example "en_GB"
will work out of the
box.
One of the advantage of using gt its consistency in using symbols and currencies in multiple languages
There are two ways to localize your results with gt.
Passing it globally gt(locale = "<locale>")
Will localize everything possible in the gt()
pipeline.
In individual fmt_()
functions
Localize buttons in opt_interactive()
Will only affect the output of one specific function (or override global setting).
locale
has very low precedence usually. As soon as you override some parameters,
sep_mark
, dec_mark
, incl_space
, they will be override locale
.
info_locales()
, info_flags()
# The Spanish locale uses `.` as thousands sep (English uses ,), and
# uses , as the decimal mark
# Using the locale in gt() will format automatically all output in subsequent
# fmt_*() calls.
exibble %>%
gt(locale = "es-AR") %>%
fmt_number()
# Only format currency as mexican peso
exibble %>%
gt(locale = "fr") %>%
fmt_currency(currency, locale = "es-MX")
# will use sep_mark provided
exibble %>%
gt(locale = "fr") %>%
fmt_currency(currency, sep_mark = "", locale = "es-MX")
# Use your imagination, and mix and match.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.