find_countrycol {countries} | R Documentation |
Finds columns containing country names
Description
This function takes a data frame as argument and returns the column name (or index) of all columns containing country names.
It can be used to automate the search of country columns in data frames.
For the purpose of this function, a country is any of the 249 territories designated in the ISO standard 3166
.
On large datasets a random sample is used for evaluating the columns.
Usage
find_countrycol(
x,
return_index = FALSE,
allow_NA = TRUE,
min_share = 0.8,
sample_size = 1000
)
Arguments
x |
A data frame object |
return_index |
A logical value indicating whether the function should return the index of country columns instead of the column names. Default is |
allow_NA |
Logical value indicating whether columns containing |
min_share |
A value between |
sample_size |
Either |
Value
Returns a vector of country names (return_index=FALSE
) or column indices (return_index=TRUE
) of columns containing country names.
See Also
is_country, country_name, find_keycol, find_timecol
Examples
find_countrycol(x=data.frame(a=c("Brésil","Tonga","FRA"), b=c(1,2,3)))