R built in list of currency symbols?

Viewed 223

Does R have any built in list of currency symbols (e.g. ¤ £ € $ ¢ ¥ ₧ ƒ) ?

Along the lines of

letters
 # [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"

but for currencies?

1 Answers

Base R does not have any built in list of currency symbols.

The easiest solution to build one is imho scraping wikipedia list of currencies for data using rvest package.

library(rvest)
library(dplyr)

url <- "https://en.wikipedia.org/wiki/List_of_circulating_currencies"

currency_tab_wiki <- url %>% read_html() %>% 
  html_nodes(xpath = "/html/body/div[3]/div[3]/div[4]/div/table[1]") %>% 
  html_table(fill = TRUE)

currency <- as_tibble(currency_tab_wiki[[1]])

head(currency, 4)
# A tibble: 4 x 6
  `State or territory[1]` `Currency[1][2]`   `Symbol[D] orAbbrev.[3]` `ISO code[2]` Fractionalunit `Numberto basic`
  <chr>                   <chr>              <chr>                    <chr>         <chr>          <chr>           
1 Abkhazia                Abkhazian apsar[E] (none)                   (none)        (none)         (none)          
2 Abkhazia                Russian ruble      ₽                        RUB           Kopek          100             
3 Afghanistan             Afghan afghani     ؋                        AFN           Pul            100             
4 Akrotiri and Dhekelia   Euro               €                        EUR           Cent           100             
Related