tags:

views:

265

answers:

3

Here is a question for R-users. I am interested in drawing a histogram with points stacked up, instead of a bar. For example if the data is (1,1,2,1,2,3,3,3,4,4), then I would like to see three points stacked up at 1, 2 points stacked up at 2 and so on. What is the best way to do this in R?

+2  A: 

Greg Snow's TeachingDemos package contains a dots(x, ...) method which seems to fit your need: http://bm2.genes.nig.ac.jp/RGM2/R%5Fcurrent/library/TeachingDemos/man/dots.html

Sol C.
Seems to be the simplest of all solutions!! Thanks Kyubic
Ramnath
+1  A: 

You can do this yourself pretty quickly:

x <- c(1,1,2,1,2,3,3,3,4,4)
plot(sort(x), sequence(table(x)))
Jonathan Chang
Thanks Jonathan. This does the job for me!
Ramnath
+1  A: 

The simplest answer I know is this:

x <- c(1,1,2,1,2,3,3,3,4,4)
stripchart(x,method="stack",at=0)

It's better than Jonathan Chang's suggestion because stripchart does proper stacking of points.

Rob Hyndman
Thanks Rob. Stripchart seems very intuitive, although I would prefer the stack of points to be separate.
Ramnath