date: Date based cleaning

Description Usage Arguments Details Value Examples

Description

Date based cleaning

Usage

1
2
3
4
5
6
7
date_standardize(x, format = "%Y-%m-%d", date_column = "date", ...)

date_missing(x, date_column = "date", drop = TRUE, ...)

date_create(x, ...)

date_create_(x, ..., .dots, format = "%Y-%m-%d", date_column = "date")

Arguments

x

(data.frame) A data.frame

format

(character) Date format. See as.Date()

date_column

(character) Name of the date column

...

Comma separated list of unquoted variable names

drop

(logical) Drop bad data points or not. Either way, we parse out bade data points as an attribute you can access. Default: TRUE

.dots

Used to work around non-standard evaluation

Details

Value

Returns a data.frame, with attributes

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
df <- sample_data_1
# Standardize dates
dframe(df) %>% date_standardize()
dframe(df) %>% date_standardize("%Y/%m/%d")
dframe(df) %>% date_standardize("%d%b%Y")
dframe(df) %>% date_standardize("%Y")
dframe(df) %>% date_standardize("%y")

# drop records without dates
NROW(df)
NROW(dframe(df) %>% date_missing())

# Create date field from other fields
df <- sample_data_2
## NSE
dframe(df) %>% date_create(year, month, day)
## SE
date_create_(dframe(df), "year", "month", "day")

scrubr documentation built on June 12, 2021, 9:06 a.m.