convertDates {CALIBERdatamanage} | R Documentation |
Applies textToDate
in the CALIBERcodelists package
repeatedly to convert each relevant column from
character to IDate (integer date).
convertDates(data, datecolnames = NULL, verbose = TRUE)
data |
data.table which contains the columns to be converted. |
datecolnames |
optional vector of names of date columns. If some of these columns are not in data, they are ignored. |
verbose |
whether to print a message stating which columns were converted. |
If date conversion is unsuccessful, the column is left in its original form (character or factor).
The modified data.table or ffdf. If data
is a data.table, it is also updated by reference.
# Create a cohort for testing mydata <- data.table(anonpatid=1:3, indexdate=c('2010-01-01', '2009-03-05', '2008-05-06'), deathdate=c(NA, '', '2009-09-08')) # Convert dates in ffdf myffdf <- as.ffdf(mydata) myffdf <- convertDates(myffdf) print(myffdf) # Convert dates in data.table # (updated by reference so no assignment is needed) convertDates(mydata) # is the same as mydata <- convertDates(mydata) print(mydata)