I'm having trouble parsing my date time column that are currently in 'chr' type. I want the date time to be grouped by hour interval and sum corresponding values, then merge two date frames.
a <- c("2016-04-12 12:00:00", "2016-04-12 12:01:00")
b <- c(10, 20)
df_1 <- data.frame(a,b)
names(df_1) <- c('Date', 'Steps')
c1 <- c("4/12/2016 12:00:00 AM", "4/12/2016 05:00:00 PM")
d <- c(20,8)
df_2 <- data.frame(c1,d)
names(df_2) <- c('Date', 'Intensity')
df_1 (with minutes interval) to join df_2 (with hourly interval but the whole day is separated by AM PM)
I have tried converting it using as.POSIXct and ymd to datetime type but it's returning NA values. I tried below code from a post I saw before, it worked but it didn't record the PM time of the day. code below
df_1 <- aggregate(df_1["Steps"],
list(Date=cut(as.POSIXct(df_1$Date), "hour")),
sum)
Also, I wanna remove that AM PM on the second date frame.