Calculating time duration from two time values with no date in R
问题 I am trying to calculate sleep duration, in hours, from two times self-reported in a diary. I have the bed and wake times in 24-hour format (for bedtimes, for instance, "23:00" is 11PM, "0:00" is midnight, "1:00" is 1AM; for wake times, "9:00" is 9AM). I thought the difftime function would be good to extract the sleep duration, but I am running into an issue with some of the cases. df$duration2<-difftime(df$Waketime2, df$Bedtime2, units="hours") In running the syntax above, it correctly