Skip to contents

Obtain country data matching language first one or more letters

Usage

languageStartsWith(char, full.list = TRUE)

Arguments

char

character to search in languages

full.list

whether to return only name of country or full list

Value

language list or country data list matching parts of a character search on languages

See also

countryStartsWith for country search starting with specified characters, and [countryEndsWith()] for countries that end with a specified characters.

Examples

# task 1: get only language names that ends with "EN" or "en"
# note that the search in case-insensitive
languageStartsWith("eN", full.list = FALSE)
#>  [1] "English"                              
#>  [2] "English, French"                      
#>  [3] "English, Swazi"                       
#>  [4] "English, Fijian, Hindi"               
#>  [5] "English, Chinese"                     
#>  [6] "English, Manx"                        
#>  [7] "English, Swahili"                     
#>  [8] "English, Chichewa"                    
#>  [9] "English, Creole"                      
#> [10] "English, French, Kinyarwanda, Swahili"
#> [11] "English, French, Creole"              
#> [12] "English, Malay, Chinese, Tamil"       

# task 2: get only language names that ends with "chi"
languageStartsWith("chi", full.list = FALSE)
#> [1] "Chinese"             "Chinese, Portuguese"

# task 3: repeat task 2, but return full list for each country with the language
languageStartsWith("sin", full.list = TRUE)
#> $`1`
#>          name officiallanguage
#> 166 Sri Lanka   Sinhala, Tamil
#> 

# searching text with no results
languageStartsWith("er", full.list = FALSE)
#> NULL