capitalOf {r2country} | R Documentation |
Fetch the latest capital of a country
Description
With specified country name or names, get the associated capital
Usage
capitalOf
Format
An object of class list
of length 193.
Value
a list containing all countries and their corresponding capital
Examples
# view the searchable countries, return first 6
head(names(capitalOf))
#task 0: check if the capital of japan is included
#should be all in lower case
grep("japan",names(capitalOf), value = TRUE)
#task 1: check the capital of nigeria
capitalOf$nigeria
#task 2: check the capital of united states
capitalOf$`united states`
#task 3: check capital of multiple countries
capitalOf[c("slovenia","romania","malaysia")]
#task 4: what if the capital is not available
capitalOf[c("randomcountry","mexico","luxembourg")]
[Package r2country version 2.0.2.3.1 Index]