match_files_by_year_months {etl}R Documentation

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, ...)

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

Value

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

a vector of POSIXct dates matching the pattern

Examples

## Not run: 
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)
}

## End(Not run)

[Package etl version 0.4.1 Index]