[R] "Raw" histogram plots

Charilaos Skiadas cskiadas at gmail.com
Wed Feb 27 14:48:13 CET 2008


On Feb 27, 2008, at 8:16 AM, Andre Nathan wrote:

> On Wed, 2008-02-27 at 14:15 +1300, Peter Alspach wrote:
>> If I understand you correctly, you could try a barplot() on the  
>> result
>> of table().
>
> Hmm, table() does the counting exactly the way I want, i.e., just
> counting individual values. Is there a way to extract the counts  
> vs. the
> values from a table, so that I can pass them as the x and y  
> arguments to
> plot()?
>

x <- table(rbinom(20,2,0.5))
plot(names(x),x)

should do it. You can also try just plot(x). Use prop.table on table  
if you want the relative frequencies instead.

> Thanks,
> Andre

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College



More information about the R-help mailing list