Learn R Programming

etl (version 0.4.1)

match_files_by_year_months: Match year and month vectors to filenames

Description

Match year and month vectors to filenames

Extracts a date from filenames

Usage

match_files_by_year_months(
  files,
  pattern,
  years = as.numeric(format(Sys.Date(), "%Y")),
  months = 1:12,
  ...
)

extract_date_from_filename(files, pattern, ...)

Value

a character vector of files that match the pattern, year, and month arguments

a vector of POSIXct dates matching the pattern

Arguments

files

a character vector of filenames

pattern

a regular expression to be passed to fast_strptime

years

a numeric vector of years

months

a numeric vector of months

...

arguments passed to fast_strptime

Examples

Run this code
if (FALSE) {
if (require(airlines)) {
  airlines <- etl("airlines", dir = "~/Data/airlines") %>%
    etl_extract(year = 1987)
  summary(airlines)
  match_files_by_year_months(list.files(attr(airlines, "raw_dir")),
    pattern = "On_Time_On_Time_Performance_%Y_%m.zip", year = 1987)
}
}

Run the code above in your browser using DataLab