fix_mdyyyy: Coerce Character m/d/yyyy to Date

Description Usage Arguments Value Examples

View source: R/fix_mdyyyy.R

Description

Uses regular expressions to sub out a single day or month with a leading zero and then coerces to a date object.

Usage

1

Arguments

x

A character date in the form of m/d/yyyy where m and d can be single integers like 1 for January.

...

ignored.

Value

Returns a data vector

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
fix_mdyyyy(c('4/23/2017', '12/1/2016', '3/3/2013', '12/12/2012', '2013-01-01'))
## Not run: 
library(dplyr)
data_frame(
    x = 1:4,
    y = LETTERS[1:4],
    start_date = c('4/23/2017', '12/1/2016', '3/3/2013', '12/12/2012'),
    end_date = c('5/23/2017', '12/9/2016', '3/3/2016', '2/01/2012')
) %>%
mutate_at(vars(ends_with('_date')), fix_mdyyyy)

## End(Not run)

trinker/textmod documentation built on Nov. 3, 2021, 7:20 p.m.