With specified country name or names, get the associated currency
Examples
# view the searchable countries, return first 6
head(names(currencyOf))
#> [1] "afghanistan" "albania" "algeria"
#> [4] "andorra" "angola" "antigua and barbuda"
#task 0: check if the currency of spain is included
#should be all in lower case
grep("spain",names(currencyOf), value = TRUE)
#> [1] "spain"
#task 1: check the currency of spain
currencyOf$spain
#> currency symbol isocode fractionalunity
#> "Euro" "\200" "EUR" "Cent"
#task 2: check the currency of singapore list
currencyOf$singapore # return a list of singapore
#> currency symbol isocode fractionalunity
#> "Singapore dollar" "$" "SGD" "Cent"
currencyOf$singapore['symbol'] #returns the symbol
#> symbol
#> "$"
currencyOf$singapore['isocode'] #returns the iso code
#> isocode
#> "SGD"
currencyOf$singapore['fractionalunity'] #returns the fractional unit
#> fractionalunity
#> "Cent"
#task 3: check currencies of multiple countries
currencyOf[c("slovenia","romania","malaysia")]
#> $slovenia
#> currency symbol isocode fractionalunity
#> "Euro" "\200" "EUR" "Cent"
#>
#> $romania
#> currency symbol isocode fractionalunity
#> "Romanian leu" "Leu" "RON" "Ban"
#>
#> $malaysia
#> currency symbol isocode fractionalunity
#> "Malaysian ringgit" "RM" "MYR" "Sen"
#>
#task 4: what if the currency is not available
currencyOf[c("randomcountry","mexico","luxembourg")]
#> $<NA>
#> NULL
#>
#> $mexico
#> currency symbol isocode fractionalunity
#> "Mexican peso" "$" "MXN" "Centavo"
#>
#> $luxembourg
#> currency symbol isocode fractionalunity
#> "Euro" "\200" "EUR" "Cent"
#>