[Solved] Date-time data in R
First convert your dates into a date-time class using asPOSIXct df = data.frame(x = c(“2012-03-01T00:05:55+00:00”, “2012-03-01T00:06:23+00:00”, “2012-03-01T00:06:52+00:00”)) df$times = as.POSIXct(df$x, format = “%Y-%m-%dT00:%H:%M+%S”) Then extract just the hour part using format df$hour = format(df$times, ‘%H’) This give you : x times hour 1 2012-03-01T00:05:55+00:00 2012-03-01 05:55:00 05 2 2012-03-01T00:06:23+00:00 2012-03-01 06:23:00 06 3 2012-03-01T00:06:52+00:00 2012-03-01 … Read more