Skip to contents

With specified country name or names, get the associated calling code

Usage

callingCodeOf

Format

An object of class list of length 193.

Value

a list containing all countries and their corresponding calling code

Examples

# view the searchable countries, return first 6
head(names(callingCodeOf))
#> [1] "afghanistan"         "albania"             "algeria"            
#> [4] "andorra"             "angola"              "antigua and barbuda"

#task 0: check if the calling code of japan is included
#should be all in lower case
grep("japan",names(callingCodeOf), value = TRUE)
#> [1] "japan"

#task 1: check the calling code of nigeria
callingCodeOf$nigeria
#> [1] "+234"

#task 2: check the calling code of united states
callingCodeOf$`united states`
#> [1] "+1"


#task 3: check calling code of multiple countries
callingCodeOf[c("slovenia","romania","malaysia")]
#> $slovenia
#> [1] "+386"
#> 
#> $romania
#> [1] "+40"
#> 
#> $malaysia
#> [1] "+60"
#> 

#task 4: what if the calling code is not available
callingCodeOf[c("randomcountry","mexico","luxembourg")]
#> $<NA>
#> NULL
#> 
#> $mexico
#> [1] "+52"
#> 
#> $luxembourg
#> [1] "+352"
#>