R/run_timestampede.R

Defines functions run_timeStampede

Documented in run_timeStampede

#' Returns a list of dataframes evaluating datetime parsing
#' @param timestamps character vector of timestamps with minimum of day (month, day, year) data
#' @importFrom dplyr na_if
#' @importFrom lubridate parse_date_time
#' @importFrom dplyr filter
#' @export

run_timeStampede <-
        function(timestamps) {
                dataframe <- data.frame(
                                raw_timestamps = timestamps,
                                timestamps_01  = dplyr::na_if(as.character(timestamps), ""),
                                timestamps_02  = lubridate::parse_date_time(timestamps, orders = c("YmdHMS", "mdyHMS", "mdYHMS",
                                                                                                   "YmdI!MSp!", "mdyI!MSp!", "mdyI!MSp!"), truncated = 3, quiet = TRUE)
                )
                x <- list()

                x[[1]] <- dataframe
                x[[2]] <- dataframe %>%
                                dplyr::filter(!(is.na(timestamps_01)), (is.na(timestamps_02)))
                x[[3]] <- dataframe %>%
                                dplyr::filter(is.na(timestamps_01))
                names(x) <- c("ALL_DATA",
                              "FAILED_TO_PARSE",
                              "RAW_DATA_NA"
                              )
                return(x)
        }
patelm9/timeStampede documentation built on Nov. 5, 2019, 12:12 a.m.