R/etl_extract.R

Defines functions etl_extract.etl_NYCTaxicab

#' @rdname etl_load.etl_NYCTaxicab
#' @inheritParams etl::etl_extract
#' @param years a vector of integers representing the years
#' @param months a vector of integers representing the months
#' @details If a \code{year} and/or \code{month} is specified, then
#' only flight data from matching months is used.
#' @export

etl_extract.etl_NYCTaxicab <- function(obj, years = 2015, months = 1:12, ...) {
  
  valid_months <- valid_year_month(years, months, begin = "2009-01-01", end = "2016-06-01") %>%
    mutate_(url = ~paste0("https://s3.amazonaws.com/nyc-tlc/trip+data/yellow_tripdata_", 
                          substr(month_begin,1,7), ".csv"))
  
  message("Downloading flight data...")
  smart_download(obj, valid_months$url)
  invisible(obj)
}
wantpinow/NYC-Taxicab-Package documentation built on May 28, 2017, 12:57 a.m.