Learn R Programming

healthcareai (version 1.2.4)

convertDateTimeColToDummies: Converts datetime columns into dummy columns

Description

THIS FUNCTION HAS BEEN RENAMED TO splitOutDateTimeCols

Usage

convertDateTimeColToDummies(df, dateTimeCol, depth = "h",
  returnDtCol = FALSE)

Arguments

df

A data frame. Indicates the datetime column.

dateTimeCol

A string. Column name in df that will be converted into several columns.

depth

A string. Specifies the depth with which to expand extra columns (starting with a year column). 'd' expands to day, 'h' expands to hour (default), m' expands to minute, and 's' expands to second.

returnDtCol

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

Value

A data frame which now includes several columns based on time rather than just one datetime column

References

http://healthcareai-r.readthedocs.io

See Also

healthcareai

Examples

Run this code
# NOT RUN {
df <- data.frame(
  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),
  y2 = c(.8, 1, 1.2, 1.2, 1.2, 1.3, 1.3, 1)
)
splitOutDateTimeCols(df, 'dtCol')
# }

Run the code above in your browser using DataLab