diff --git a/DESCRIPTION b/DESCRIPTION index 57fa14b..009276d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Dmisc Title: Daniel miscellaneous functions -Version: 0.3.2 +Version: 0.3.3 Authors@R: person(given = "Daniel E.", family = "de la Rosa", diff --git a/R/vars_to_date.R b/R/vars_to_date.R index 6a2c4c3..e1b2c41 100644 --- a/R/vars_to_date.R +++ b/R/vars_to_date.R @@ -19,7 +19,6 @@ #' @export #' #' @examples -#' \dontrun{ #' tbl <- data.frame( #' year = rep("2021", 12), #' month = month.name, @@ -30,7 +29,25 @@ #' tbl #' #' vars_to_date(tbl, year = 1, month = 2, day = 3) -#' } +#' +#' # y soporta varias frecuencias y formatos de fechas +#' +#' tbl <- data.frame( +#' year = rep("2021", 12), +#' quarter = sample( +#' c( +#' "Enero-Marzo", +#' "Abril-Junio", +#' "Julio-Septiembre", +#' "Octubre-Diciembre" +#' ) +#' ), +#' value = sample(100:1000, 12, TRUE) +#' ) +#' +#' tbl +#' +#' vars_to_date(tbl, year = 1, quarter = 2) vars_to_date <- function( tbl, year = NULL, quarter = NULL, month = NULL, day = NULL, date = NULL, drop_vars = TRUE, diff --git a/man/vars_to_date.Rd b/man/vars_to_date.Rd index 706bcc1..f1df5b0 100644 --- a/man/vars_to_date.Rd +++ b/man/vars_to_date.Rd @@ -51,7 +51,6 @@ Multiple variables to unique date variable \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} } \examples{ -\dontrun{ tbl <- data.frame( year = rep("2021", 12), month = month.name, @@ -62,5 +61,23 @@ tbl <- data.frame( tbl vars_to_date(tbl, year = 1, month = 2, day = 3) -} + +# y soporta varias frecuencias y formatos de fechas + +tbl <- data.frame( + year = rep("2021", 12), + quarter = sample( + c( + "Enero-Marzo", + "Abril-Junio", + "Julio-Septiembre", + "Octubre-Diciembre" + ) + ), + value = sample(100:1000, 12, TRUE) +) + +tbl + +vars_to_date(tbl, year = 1, quarter = 2) }