# some data
flights = data.frame(DEP_TIME_BLK = c("0001-0559","0600-0659","1100-
1159","1200-1259","1300-1359","1900-1959","2300-2359"))
# Choose when dayparts begin; 600 ~ 06:00 etc.
dayparts_start <- c(morning = 600, afternoon = 1300, evening = 1800, night =
2300)
# Here I only use endtime from DEP_TIME_BLK to determine daypart bin
endtime <- as.numeric(gsub("\\d+-", "", flights$DEP_TIME_BLK))
# binning endtimes to daypart bins using cut and then mapping the numeric bins to names
dayparts_bins <- as.numeric(cut(endtime, breaks = c(0,dayparts_start, 2400)))
flights$dayparts_bins_names <- plyr::mapvalues(dayparts_bins, 1:5,
c("night", "morning", "afternoon", "evening", "night") )
flights
DEP_TIME_BLK dayparts_bins_names
1 0001-0559 night
2 0600-0659 morning
3 1100-1159 morning
4 1200-1259 morning
5 1300-1359 afternoon
6 1900-1959 evening
7 2300-2359 night
It's a crude approach, but it might get you started.