Converts all date columns in a data.table from character to IDate
textToDate in the CALIBERcodelists package
repeatedly to convert each relevant column from
character to IDate (integer date).
data.table which contains the columns to be converted.
optional vector of names of date columns. If some of these columns are not in data, they are ignored.
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.
1 2 3 4 5 6 7 8 9 10 11 12 13
# 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 mydaat <- convertDates(mydata) print(mydata)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.