How to plot time in a range in R?

I have a dataframe df as

Time           Day
2:03:00 AM     Wed
2:02:00 AM     Wed
1:56:00 AM     Mon
1:54:00 AM     Tue
1:53:00 AM     Mon
1:51:00 AM     Sun
1:51:00 AM     Sun
1:50:00 AM     Sun
1:48:00 AM     Sun

I want to plot a graph where I can plot the time in a range like 12am-2am, 2am-4am, and so on vs day

Please help.

Answers


Think this is essentially what you are after

data <- data.frame(Time=c("2:03:00 AM", "2:02:00 AM", "1:56:00 AM", "1:54:00 AM", "1:53:00 AM", "1:51:00 AM", "1:51:00 AM", "1:50:00 AM", "1:48:00 AM"), 
                   Day=c("Wed", "Wed", "Mon", "Tue", "Mon", "Sun", "Sun", "Sun", "Sun")) 
data$Day <- factor(data$Day,levels=c("Mon","Tue","Wed","Thu","Fri","Sat","Sun"))
data2 <- strptime(paste(data$Time, as.numeric(data$Day), data$Day,sep=" "), format="%H:%M:%S %p %d %a")
hist(data2, breaks="hours", start.on.monday=TRUE, format="%H:%M:%S %p %d")

Need Your Help

Techniques for condensing code

python python-3.x

As I understand it, python is specifically designed to force people to use indentation but is it possible to break this rule. As an example:

Designing an iterator wrapper

c++ stl iterator wrapper

I wrote a class that wraps an iterator and returns transformed values on demand: