我有一個合理的時間數據量,我想把它放在一個頻率圖中,其中X軸將是幾個時間間隔,Y軸會是我在這段時間收集的數據量。看到這個例子:在R中繪製事件的時間頻率隨着時間的推移
讓我們假設我有這樣的名單:
[10:17:55, 10:37:40, 10:40:26, 10:48:18, 11:00:17, 11:01:12, 11:06:58, 11:09:20, 11:43:41, 11:48:24, 11:49:14, 12:07:31, 12:10:52, 12:10:52, 12:19:00, 12:19:00, 12:19:43, 12:20:55, 12:38:27, 12:38:27, 12:55:09, 12:55:10, 12:57:31, 12:57:31, 13:04:16, 13:04:16, 13:06:51 13:06:51, 14:55:06, 14:56:10, 15:01:30, 15:28:42, 3:29:17, 15:35:33, 15:58:32, 16:05:07, 16:09:16, 16:10:36, 16:32:57, 16:32:57, 16:34:32, 16:38:16, 17:43:27, 17:53:01, 17:56:14, 18:08:21, 18:17:23, 18:37:23, 18:37:23, 18:43:13, 18:43:13 18:51:43, 18:51:43, 19:05:39, 19:05:39]
而且我想繪製顯示多少個值在1小時的間隔,或30分鐘(還沒有決定)是有一個柱狀圖,如:
10h - 11h: 4
11h - 12h: 7
.
.
.
19h - 20h: 2
但是,所有在圖表中表示。我知道如何在R中繪製直方圖的基本知識,但無法弄清楚如何做到這一點。我已經看到了一些在整個日子裏做出陰謀的答案,這並不適用,因爲這些價值是在不同的日子裏收集的......你們能幫助我嗎?
編輯:下面是列表的dput()
:
structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
13L, 13L, 14L, 14L, 15L, 16L, 17L, 17L, 18L, 19L, 20L, 20L, 21L,
21L, 22L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L,
33L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 41L, 42L, 42L,
43L, 43L, 44L, 44L), .Label = c("10:17:55", "10:37:40", "10:40:26",
"10:48:18", "11:00:17", "11:01:12", "11:06:58", "11:09:20", "11:43:41",
"11:48:24", "11:49:14", "12:07:31", "12:10:52", "12:19:00", "12:19:43",
"12:20:55", "12:38:27", "12:55:09", "12:55:10", "12:57:31", "13:04:16",
"13:06:51", "14:55:06", "14:56:10", "15:01:30", "15:28:42", "15:29:17",
"15:35:33", "15:58:32", "16:05:07", "16:09:16", "16:10:36", "16:32:57",
"16:34:32", "16:38:16", "17:43:27", "17:53:01", "17:56:14", "18:08:21",
"18:17:23", "18:37:23", "18:43:13", "18:51:43", "19:05:39"), class = "factor")`
假設他們是日期:'HIST(as.numeric(格式(hour_dat,「%H」)),符= 24)'基本上你想先隔離小時。格式會吐出一個字符,所以你需要轉換爲數字。 – Badger
當我收集它們時,我抑制了日期值。我想現在他們是純粹的時間數據...如果是這樣的話我將如何繼續?當我嘗試應用您的解決方案時,會拋出「無效」修剪「參數」。 –
請'dput()'您的數據。 –