I have a basic character date to POSIXct function
charDateToPosixct <- function(chrDate, format, timeZone) { as.POSIXct(chrDate, format=format, tz=timeZone) } I have a data frame with date as character and timezone.
chrDate <- c("4/25/2012","4/24/2012","4/16/2012","6/30/2012") timeZone <- c("US/Eastern","US/Central","US/Pacific","US/Eastern") df <- data.frame(date=chrDate,timezone=timeZone) str(df) 'data.frame': 4 obs. of 2 variables: $ date : Factor w/ 4 levels "4/16/2012","4/24/2012",..: 3 2 1 4 $ timezone: Factor w/ 3 levels "US/Central","US/Eastern",..: 2 1 3 2 I want to change the data type of date to POSIXct and so want to apply this function charDateToPosixct to each row with the format "%m/%d/%y".