find_timecol {countries} | R Documentation |
Finds columns containing date and year data
Description
This function takes a data frame as argument and returns the column names (or indices) of all columns containing dates and the most likely column containing year information, if any. It can be used to automate the search of date and year columns in data frames.
Usage
find_timecol(x, return_index = FALSE, allow_NA = TRUE, sample_size = 1000)
Arguments
x |
A data frame object |
return_index |
A logical value indicating whether the function should return the index of time columns instead of the column names. Default is |
allow_NA |
Logical value indicating whether to allow time columns to contain |
sample_size |
Either |
Value
Returns a vector of names (return_index=FALSE
) or indices (return_index=TRUE
) of columns containing date or year information. Only the most likely year column is returned.
See Also
Examples
find_timecol(x=data.frame(a=1970:2020, year=1970:2020, b=rep("2020-01-01",51),c=sample(1:1000,51)))