I'm trying to split a column that contains both a date and time to seperate time, day, month, year, dayofweek, hour and minute columns. I'm able to split the columns but the only problem is that the AM and PM times are not separating and the only times showing are 1 - 12 instead of splitting out the AM and PM hours even though the original dataset uses the 24hr time. I was wondering if anyone knows a way to do this?
The code I'm using to split the column is:
taxijuly$Trip.Start.Timestamp <- as.POSIXct(taxijuly$Trip.Start.Timestamp, format = "%m/%d/%Y %H:%M:%S")
taxijuly$Time <- format(as.POSIXct(taxijuly$Trip.Start.Timestamp, format = "%m/%d/%Y %H:%M:%S"), format="%H:%M:%S")
taxijuly$Trip.Start.Timestamp <- ymd_hms(taxijuly$Trip.Start.Timestamp)
taxijuly$day <- factor(day(taxijuly$Trip.Start.Timestamp))
taxijuly$month <- factor(month(taxijuly$Trip.Start.Timestamp, label = TRUE))
taxijuly$year <- factor(year(taxijuly$Trip.Start.Timestamp))
taxijuly$dayofweek <- factor(wday(taxijuly$Trip.Start.Timestamp, label = TRUE))
taxijuly$hour <- factor(hour(hms(taxijuly$Time)))
taxijuly$minute <- factor(minute(hms(taxijuly$Time)))
taxijuly$second <- factor(second(hms(taxijuly$Time)))
and the data in the column I'm trying to split looks like this:
Trip Start Timestamp
09/03/2019 00:00
09/03/2019 00:00
09/03/2019 00:00
09/03/2019 00:00
Any help would be hugely appreciated.