convertDates: Converts all date columns in a data.table from character to...

Description Usage Arguments Details Value See Also Examples

Description

Applies textToDate in the CALIBERcodelists package repeatedly to convert each relevant column from character to IDate (integer date).

Usage

1
convertDates(data, datecolnames = NULL, verbose = TRUE)

Arguments

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.

Details

If date conversion is unsuccessful, the column is left in its original form (character or factor).

Value

The modified data.table or ffdf. If data is a data.table, it is also updated by reference.

See Also

textToDate

Examples

 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)


Search within the CALIBERdatamanage package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.