Skip to content

coerce IDates to dates when standarizing dates #254

Description

@gmatov

Please place an "x" in all the boxes that apply

  • I have the most recent version of this package and R
  • I have found a bug
  • I have a reproducible example
  • I want to request a new feature

Please include a brief description of the problem with a code example:

Could cleanepi coerce IDates to dates when standarizing dates?

library(magrittr)

covid <- rio::import("https://epiverse-trace.github.io/tutorials-early/data/covid_simulated_data.csv") %>% 
  dplyr::as_tibble()

clean_covid <- covid %>% 
  cleanepi::standardize_column_names() %>% 
  cleanepi::remove_duplicates() %>% 
  cleanepi::standardize_dates(target_columns = c("date_onset"))
#> ! Found 1915 duplicated rows in the dataset.
#> ℹ Use `attr(dat, "report")[["duplicated_rows"]]` to access them, where "dat" is
#>   the object used to store the output from this operation.

clean_covid$date_onset %>% class()
#> [1] "IDate" "Date"

clean_covid %>% 
  cleanepi::timespan(target_column = "date_onset", end_date = Sys.Date(), span_unit ="days")
#> Warning in lubridate::as.period(end_date - data[[target_column]]): Incompatible
#> methods ("-.Date", "-.IDate") for "-"
#> Error in lubridate::as.period(end_date - data[[target_column]]): as.period is not defined for class 'IDate'as.period is not defined for class 'Date'

Created on 2025-08-13 with reprex v2.1.1


Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions