Skip to content
Prev 392265 / 398502 Next

Extract time and state of charge (Start and End) and Count

Hello,

I'm not sure I understand the problem. Do you want counts of how many 
rows are there per hour?


# these columns need to be fixed
cols <- c("BatteryChargeStartDate", "BatteryChargeStopDate")
dt_2014[cols] <- lapply(dt_2014[cols], \(x) sub("\n", " ", x))
# use package lubridate to coerce to a datetime class
dt_2014[cols] <- lapply(dt_2014[cols], lubridate::dmy_hm)

h <- lubridate::hour(dt_2014[["BatteryChargeStartDate"]])
aggregate(Starting_SoC_of_12 ~ h, dt_2014, length)



It would be better if you post the expected output corresponding to the 
posted data set.

Hope this helps,

Rui Barradas

?s 05:04 de 18/07/2022, roslinazairimah zakaria escreveu: