colToDate | R Documentation |
This function converts a character column in a data frame to time and then strips out day and hour of the time as new columns. The output is a new data frame with one modified column (character converted to date) and two new columns (day of week and hour of day).
colToDate(dat, dateColName, dateFormat)
dat |
This is the data source to be converted |
dateColName |
This is the name of the date column to be converted |
dateFormat |
This is the format of the date column |
testDat <- data.frame(stringsAsFactors = FALSE, time = c("2016-10-31","2016-12-25","2016-07-04"),event = c("Halloween","Christmas","US Independence Day"))
testDat <- colToDate(testDat,"time","%Y-%m-%d")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.