[R] Counting things in a time series.

Noah Silverman noah at smartmediacorp.com
Sun Nov 21 06:29:57 CET 2010


Hi,

I have a process (not in R) that records events with a time stamp.  So,
I have a huge series of maybe 100,000 time stamps.

I'd like to break it up into hourly (Or daily) intervals and then count
how many events occurred in each interval.  That way I can graph it.

Ideally, converting the this into a time series in R would let me do
some interesting analysis.

The data is just a list of epoch timestamps.  Importing into R is
trivial but I'm stuck from there.

1) How can I "bin" the counts by an hour?  One thought would be to
divided each timestamp by 3600, them multiply back by 1000.  This would
effectively convert them to hours with multiple entries per hour. ) 
But, I then don't know how to count them

2) Once I figure out the counts, I'll then have a data structure with a
column of epoch seconds and a second column of counts.  How can I then
convert that into a ts object?

Thanks!

-N



More information about the R-help mailing list