date: Date based cleaning

dateR Documentation

Date based cleaning

Description

Date based cleaning

Usage

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

  • date_standardize - Converts dates to a specific format

  • date_missing - Drops records that do not have dates, either via being NA or being a zero length character string

  • date_create - Create a date field from

Value

Returns a data.frame, with attributes

Examples

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")

ropenscilabs/scrubr documentation built on Sept. 12, 2022, 4:10 p.m.