r - calculate transactions per second
If I have a dataset with a date as such:
head(ds$TransStartTmdte)
[1] "2011-05-09 08:50:12" "2011-05-09 09:03:46" "2011-05-09 09:06:49" "2011-05-09 09:13:05" "2011-05-09 14:21:58" "2011-05-09 14:23:00"
Where each row repressents a "transaction" how can I calculate transactions per second.
The date format is POSIXt
dput(head(ds$TransStartTmdte))
structure(list(sec = c(0.007, 0.013, 0.018, 0.012, 0.043, 0.039
), min = c(34L, 34L, 34L, 34L, 34L, 34L), hour = c(14L, 14L,
14L, 14L, 14L, 14L), mday = c(9L, 9L, 9L, 9L, 9L, 9L), mon = c(4L,
4L, 4L, 4L, 4L, 4L), year = c(111L, 111L, 111L, 111L, 111L, 111L
), wday = c(1开发者_C百科L, 1L, 1L, 1L, 1L, 1L), yday = c(128L, 128L, 128L,
128L, 128L, 128L), isdst = c(1L, 1L, 1L, 1L, 1L, 1L)), .Names = c("sec",
"min", "hour", "mday", "mon", "year", "wday", "yday", "isdst"
), class = c("POSIXlt", "POSIXt"))
Is this works for you?
table(cut(transactionTime, "secs"))
Example:
plot(table(cut(ds$TransStartTmdte, "secs")), main=mydataset ,xlab="date ", ylab="Trans",pch=20)
精彩评论