multidate: Read Dates from varying forms

Description Usage Arguments Value Examples

Description

Useful for combining with apply when columns have various date formats

Usage

1
multidate(data, formats = c("%m%d%Y", "%m-%d-%y", "%m/%d/%Y"))

Arguments

data

Data Set (for piping)

formats

Character vector containing the various date formats

Value

single Date object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
multidate("03121989")
multidate("03-12-89")
multidate("03/12/1989")

##Not Run
library(tidyverse)
date_list = list(c("03121989","03-12-89","03/12/1989"))
dates = lapply(date_list, multidate)[[1]]

##Can also adpat to different formats for apply
date_list = list(c("128903","12198903","03/-12/-1989"))
my_multidate = function(x){
multidate(data = x, formats = c("%d%y%m","%d%Y%m","%m/-%d/-%Y"))
}
dates = lapply(date_list, my_multidate)[[1]]

Ajfrick/AVRCHelp documentation built on May 28, 2019, 1:34 a.m.