Title: | Standardize Dates in Different Formats or with Missing Data |
---|---|
Description: | There are many different formats dates are commonly represented with: the order of day, month, or year can differ, different separators ("-", "/", or whitespace) can be used, months can be numerical, names, or abbreviations and year given as two digits or four. 'datefixR' takes dates in all these different formats and converts them to R's built-in date class. If 'datefixR' cannot standardize a date, such as because it is too malformed, then the user is told which date cannot be standardized and the corresponding ID for the row. 'datefixR' also allows the imputation of missing days and months with user-controlled behavior. |
Authors: | Nathan Constantine-Cooke [aut, cre] , Jonathan Kitt [ctb, trl], Antonio J. PĂ©rez-Luque [ctb, trl] , Daniel Possenriede [ctb, trl] , Michal Lauer [ctb, trl], Kaique dos S. Alves [rev] , Al-Ahmadgaid B. Asaad [rev] , Anatoly Tsyplenkov [ctb, trl] , Chitra M. Saraswati [ctb, trl] |
Maintainer: | Nathan Constantine-Cooke <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.7.0.9000 |
Built: | 2024-10-19 15:41:27 UTC |
Source: | https://github.com/ropensci/datefixR |
A toy dataset to use with datefixR functions.
exampledates
exampledates
A data frame with 5 rows and 3 variables:
Row ID (numeric).
Dates in different formats (character).
Additional dates in different formats (character).
A shiny application which allows users to standardize dates
using a graphical user interface (GUI). Most features of datefixR
are supported including imputing missing date data. Data can be provided as
CSV (comma-separated value) or XLSX (Excel) files. Processed datasets can
be downloaded as CSV files. Please note, the dependencies for this app
(DT
, htmltools
, readxl
, and shiny
) are not
installed alongside datefixR
. This allows datefixR
to be
installed on secure systems where these packages may not be allowed. If one
of these dependencies is not installed on the system when this function is
called, then the user will be given the option of installing them.
fix_date_app(theme = "datefixR")
fix_date_app(theme = "datefixR")
theme |
Color theme for shiny app. Either |
A shiny app.
The shiny
package.
## Not run: fix_date_app() ## End(Not run)
## Not run: fix_date_app() ## End(Not run)
Date
classConverts a character vector (or single character object) from inconsistently
formatted dates to R's Date
class. Supports numerous separators
including /, -, or space. Supports numeric, abbreviation or long-hand
month notation. Where day of the month has not been supplied, the first day
of the month is imputed by default. Either DMY or YMD is assumed by default.
However, the US system of MDY is supported via the format
argument.
fix_date_char( dates, day.impute = 1, month.impute = 7, format = "dmy", excel = FALSE, roman.numeral = FALSE )
fix_date_char( dates, day.impute = 1, month.impute = 7, format = "dmy", excel = FALSE, roman.numeral = FALSE )
A vector of elements belonging to R's built in Date
class
with the following format yyyy-mm-dd
.
fix_date_df
which is similar to fix_date_char()
except is applicable to columns of a data frame.
bad.date <- "02 03 2021" fixed.date <- fix_date_char(bad.date) fixed.date
bad.date <- "02 03 2021" fixed.date <- fix_date_char(bad.date) fixed.date
Tidies a dataframe
object which has date columns
entered via a free-text box (possibly by different users) and are therefore
in a non-standardized format. Supports numerous separators including /,-, or
space. Supports all-numeric, abbreviation, or long-hand month notation. Where
day of the month has not been supplied, the first day of the month is
imputed. Either DMY or YMD is assumed by default. However, the US system of
MDY is supported via the format
argument.
fix_date_df( df, col.names, day.impute = 1, month.impute = 7, id = NULL, format = "dmy", excel = FALSE, roman.numeral = FALSE )
fix_date_df( df, col.names, day.impute = 1, month.impute = 7, id = NULL, format = "dmy", excel = FALSE, roman.numeral = FALSE )
A dataframe
or tibble
object. Dependent on the type of
df
. Selected columns are of type Date
with the following
format yyyy-mm-dd
fix_date_char
which is similar to fix_date_df()
except can only be applied to character vectors.
data(exampledates) fixed.df <- fix_date_df(exampledates, c("some.dates", "some.more.dates")) fixed.df
data(exampledates) fixed.df <- fix_date_df(exampledates, c("some.dates", "some.more.dates")) fixed.df