[R] Own classes in "histogram"

David Hewitt dhewitt37 at gmail.com
Wed Jan 16 18:16:55 CET 2008



Denis Aydin wrote:
> 
> I try to make a histogram from a variable that contains the number of
> shoots from about 1000 individuals from a specific plant species (the
> range is 1-110).
> Those numbers are highly skewed to the right.
> 
> My question is: how can I make my own classes with the lattice
> "histogram"?
> 
> I tried it with "breaks=c(0,5,10,15,20,25,110)" but my "25-110"-class is
> presented
> as one huge bin ranging from 25 to 110.
> Is there a way to plot this bin in equal size as the others?
> And how is it possible to change the annotation of the x-axis, let's
> say the last tick named ">25"?
> 

There may be a more elegant way to do this within 'hist', but you can create
the binned data with hist and then plot it with 'barplot' to get even width
bars:

tmp1 <- hist(your.data, breaks=c(0, 5, 10, 15, 20, 25, 110))

barplot(tmp1$counts, names.arg=c("0", "5", "10", "15", "20", "25", ">25"))

The names.arg list handles the x-axis labels, as you wished.

-----
David Hewitt
Virginia Institute of Marine Science
http://www.vims.edu/fish/students/dhewitt/
-- 
View this message in context: http://www.nabble.com/Own-classes-in-%22histogram%22-tp14883184p14886370.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list