On Fri, 2009-04-24 at 13:12 -0700, sjaffe 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
Hi Steve In your only 3 cells > 0 > d b.1 b (0,1] (1,2] (2,3] (3,4] (4,5] (5,6] (6,7] (7,8] (8,9] (9,10] (0,1] 0 0 0 0 0 0 0 0 0 0 (1,2] 0 1 0 0 0 0 0 0 0 0 (2,3] 0 0 1 0 0 0 0 0 0 0 (3,4] 0 0 0 0 0 0 0 0 0 0 (4,5] 0 0 0 0 0 0 0 0 0 0 (5,6] 0 0 0 0 0 0 0 0 0 0 (6,7] 0 0 0 0 0 0 0 0 0 0 (7,8] 0 0 0 0 0 0 0 0 0 0 (8,9] 0 0 0 0 0 0 0 0 0 0 (9,10] 0 0 0 0 0 0 0 0 0 1 If you desire use simple code to find only cell>0 use this table(interaction(c,drop=T)) (1,2].(1,2] (2,3].(2,3] (9,10].(9,10] 1 1 1 -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil ______________________________________________ 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.