I have this vector in a data frame of times in the format of hours:minutes that I want converted to categorical times of day:
time <- c(\"15:03\", \"0
This one is similar to @Onyambu, only using plyr's mapvalues() and lubridate's hour():
plyr
mapvalues()
lubridate
hour()
library(lubridate) library(plyr) df$timeofdat<- mapvalues(hour(df$time),from=c(0:23), to=c(rep("night",times=5), rep("morning",times=6),rep("afternoon",times=5),rep("night", times=8)))