On Fri, Apr 24, 2009 at 3:12 PM, sjaffe <sja...@riskspan.com> wrote: > > small example: > > a<-c(1.1, 2.1, 9.1) > b<-cut(a,0:10) > c<-data.frame(b,b) > d<-table(c) > dim(d) > ##result: c(10, 10) > > But only 9 of the 100 cells are non-zero. > If there were 10 columns, the table have 10 dimensions each of length 10, so > have 10^10 elements, too much even to fit in memory
Here's one way with the plyr package: library(plyr) ddply(c, names(c), nrow) Find more about plyr at http://had.co.nz/plyr Hadley -- http://had.co.nz/ ______________________________________________ R-help@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.