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

Description Usage Arguments Details Value See Also Examples

View source: R/convertDates.R

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)

CALIBERdatamanage documentation built on May 31, 2017, 3:41 a.m.

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