I have a set of UNIX timestamps and URIs and I'm trying to plot the cumulative count of requests for each URI. I managed to do that for one URI at a time using a dummy column:
x.df$count <- apply(x.df,1,function(row) 1) # Create a dummy column for cumsum
x.df <- x.df[order(x.df$time, decreasing=FALSE),] # Sort
ggplot(x.df, aes(x=time, y=cumsum(count))) + geom_line()
However, that would make roughly 30 plots in my case.
ggplot2 does allow you to plot multiple lines into one plot (I copied this piece of code from here):
ggplot(data=test_data_long, aes(x=date, y=value, colour=variable)) +
geom_line()
The problem is that, this way, cumsum()
would count on and on.
Does anybody have an idea?
plyr
ordata.table
. Split the data by URI then to yourcumsum
on each piece.data.table(x); x[, list(count=.I), by=URI]
Or something like that... – Lubbi