[R] Histogram

Ben Bolker bolker at zoo.ufl.edu
Tue Nov 18 16:49:21 CET 2003



plot(table(factor(x,levels=c("c","b","a"))))

is at least approximately what you want (the only complicated bit is 
reversing the order of the bars from the default alphabetical order)

substituting barplot() for plot() also works

you may want to use ylab="something" in the plot or barplot command to get 
a more descriptive axis label

On 18 Nov 2003, Arend P. van der Veen wrote:

> Hi,
> 
> I have what should be a simple question.  I would like to generate a
> histogram of
> 
> x <- c("a","b","c","b","c","c")
> 
> where the first bar to be labeled 'c' with height 3, second bar to be
> labeled 'b' with height 2 and third bar to be labeled 'a' with height 1.
> 
> This should be an easy task in R but I think I am missing something?
> 
> Thanks,
> Arend van der Veen
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 

-- 
620B Bartram Hall                            bolker at zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704




More information about the R-help mailing list