R/extract_dates.R

Defines functions extract_dates

Documented in extract_dates

#' a function spliting dates and times
#'
#' This function splits Dates and Times
#'
#' @param data.komp The input data
#' @param dataColumn The column containing dates and times both
#'
#' @return data.komp The output data with two new columns (Date.New and Time.New)
#'
#' @examples
#'
#' @export
#'

extract_dates <- function (data.komp, dataColumn) {
  data1 <- do.call(rbind, strsplit(data.komp$dataColumn," "))
  data1[1] <- mdy(data1[1])
  data1[2] <- strptime(data1[2], "%H:%M")
  colnames(data1) <- c(paste(data.komp, ".",dataColumn, ".Date.New", sep = ""), paste(data.komp, ".",dataColumn, ".Time.New", sep = ""))
  data.komp <- cbind(data.komp, data1)
  data.komp
}
dleelab/KompUtils documentation built on May 13, 2017, 3:31 a.m.