我在數據框中有一段POSIXlt時間,並且我正在嘗試查看每天有多少次這些事件(在這種情況下是騎自行車)。什麼是最好的方式來做到這一點?按天計算POSIXlt時間
的日期是這樣的:
> rides$start.fmtd[1:25]
[1] "2014-01-01 00:06:00" "2014-01-01 00:11:00" "2014-01-01 00:12:00"
[4] "2014-01-01 00:14:00" "2014-01-01 00:15:00" "2014-01-01 00:16:00"
[7] "2014-01-01 00:16:00" "2014-01-01 00:19:00" "2014-01-01 00:20:00"
[10] "2014-01-01 00:20:00"
dput(head())
給了我這樣的:
> dput(head(rides$start.fmtd))
structure(list(sec = c(0, 0, 0, 0, 0, 0), min = c(6L, 11L, 12L,
14L, 15L, 16L), hour = c(0L, 0L, 0L, 0L, 0L, 0L), mday = c(1L,
1L, 1L, 1L, 1L, 1L), mon = c(0L, 0L, 0L, 0L, 0L, 0L), year = c(114L,
114L, 114L, 114L, 114L, 114L), wday = c(3L, 3L, 3L, 3L, 3L, 3L
), yday = c(0L, 0L, 0L, 0L, 0L, 0L), isdst = c(0L, 0L, 0L, 0L,
0L, 0L)), .Names = c("sec", "min", "hour", "mday", "mon", "year",
"wday", "yday", "isdst"), class = c("POSIXlt", "POSIXt"))
這個特定的幀有大約300,000慶祝活動(這是首都bikeshare數據集,其中包含在採取一切騎自行車該系統每季打包一次)。
你能張貼'dput(頭(yourDataFrame))'的輸出提供數據的樣本? '表(as.Date(yourDataFrame $ posixLtVariable))'應該工作? –
'表(as.date(frame $ column))'工作!但是我在框架中有大約30萬個觀察值,所以我不能'dput()'吐出合理數量的數據。 –
@JakeBurkhead做出答案。 'as.Date()'可以讓我將日期保存爲表格標籤,而'frame $ yday'不會讓我輕鬆做到這一點。 –