[R] Vectorize tapply(...,cumsum) output

From: Gerrit Draisma <g.draisma_at_erasmusmc.nl>
Date: Wed, 09 Apr 2008 14:53:41 +0200


I would like to graph cumulative counts
and use tapply(...,cumsum) to get
the cumulative counts.
For instance:

    library(lattice)

    t<-rep(1:4,each=3)    #time
    i<-rep(1:3,times=4)   #categories
    n<-rpois(length(t),t) #count

    xyplot(n ~ t,groups=i,
    type="o",key=simpleKey(as.character(1:3),x=0,y=1,lines=T))     N<-tapply(n,t,cumsum)

Now, what is the best way to convert N
to a vector that can be plotted?
E.g.

    xyplot(N ~ t,groups=i,
    type="o",key=simpleKey(as.character(1:3),x=0,y=1,lines=T))

Or is there a better way to get cumulative graphs?

Thanks,
Gerrit.



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 09 Apr 2008 - 12:56:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 09 Apr 2008 - 13:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive