Learn R Programming

healthcareai (version 1.2.4)

countDaysSinceFirstDate: Creates column based on days since first date

Description

Adds a new column to the data frame, which shows days since first day in input column

Usage

countDaysSinceFirstDate(df, dtCol, returnDtCol = FALSE)

Arguments

df

A data frame

dtCol

A string denoting the date-time column of interest

returnDtCol

A boolean. Return the original dtCol with the modified data frame?

Value

A data frame that now has a new column

References

http://healthcareai-r.readthedocs.io

See Also

healthcareai

Examples

Run this code
# NOT RUN {
dtCol = c('2001-06-09 12:45:05','2002-01-29 09:30:05','2002-02-02 07:36:50',
'2002-03-04 16:45:01','2002-11-13 20:00:10','2003-01-29 07:31:43',
'2003-07-07 17:30:02','2003-09-28 01:03:20')
y1 <- c(.5,1,3,6,8,13,14,1) # Not being used at all
df <- data.frame(dtCol, y1)
head(df)
dfResult <- countDaysSinceFirstDate(df, 'dtCol')
head(dfResult)
# }

Run the code above in your browser using DataLab