2014-03-05 55 views
0

我有一個數據幀DF作爲如何在R的範圍內繪製時間?

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 

我要繪製圖表,我可以積的時間範圍像12 am-2am,2 am-4am,等等VS天

請幫助。

+0

是逆時序數據之後? –

+0

是的,它是@RScriv –

+0

你想繪製什麼值?你在每個時間範圍有多個值嗎? –

回答

1

認爲這基本上是你是什麼

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") 
+0

非常感謝..它幫助! –

相關問題