# Modeling frequency over time

I have a two-dimensional data set that looks like $(t, x)$ where $t$ is a time in seconds when event $X$ happened. $X$ ranges from $[0, 200]$.

I want to visualize the frequency of each $x$ at time $t$ over some time period. I guess this would be a bar graph with $x$-axis being event #, $y$-axis being frequency, and $z$-axis being time, $t$.

Furthermore, I would like to group all events that happen within say a 5 second interval to count towards the same frequency bar on the $y$-axis.

If there is a way to do this with R that would be even better.

My goal is to get a sense how often some event occurs over the course of a day, and when certain events happen a lot or infrequently. If you know of a better way to understand this information, I am all ears.

-
It might help if you showed us some data (invented if necessary) which illustrates your question. –  Henry May 11 '11 at 20:18
@Henry that is actually exactly what the data looks like: (1, 3), (1, 4), (2.4, 4), ... where x is time in seconds and the y coordinate is [0,200] –  Andrew Warner May 11 '11 at 20:25

The key thing is you "want to visualize the frequency of each X at time t over some time period.". Here is a starter with the straightforward methods. Which method to use will very much depend on how your actual data looks.

# generate data
n <- 10000
mydata <- data.frame(
Time=rexp(n, 5),
X=runif(n))

First method - straightforward point plot, using transparency to avoid over-plotting problems

library(ggplot2)
ggplot(mydata, aes(x=Time, y=X)) +
geom_point(alpha=0.1)

Second method - turn Time into a discrete variable and show box plots

mydata$Time.f <- cut(mydata$Time, breaks=20)
ggplot(mydata, aes(x=Time.f, y=X)) +
geom_boxplot() +
coord_flip()

-
I think he wants 5 sec. binning. I also assume his X are integral and hence each X could get its own count over every 5 sec interval. –  curious_cat Mar 20 at 10:02