Re: [R] Own classes in "histogram"
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. __ 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.
Re: [R] Own classes in "histogram"
On 1/16/08, Denis Aydin <[EMAIL PROTECTED]> wrote: > Hi, > > 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. I would suggest you consider transforming the values first (log or square root would be typical); that might address the problems caused by skewness. > 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. Yes, that's how it's supposed to be in a ``histogram''. > Is there a way to plot this bin in equal size as the others? Yes, but the result is no longer a histogram but a bar plot. You can discretize your data into a factor with appropriate levels using the 'cut' function; e.g. something like xdisc <- cut(x, breaks=c(0,5,10,15,20,25,110)) and then plot it using barchart(table(xdisc)) ## or perhaps barchart(table(xdisc), horizontal=FALSE) > And how is it possible to change the annotation of the x-axis, let's > say the last tick named ">25"? The easiest way is to change the relevant label, e.g. levels(xdisc)[6] <- "> 25" -Deepayan __ 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.
[R] Own classes in "histogram"
Hi, 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"? Thanks for any help! Regards, Denis __ Denis Aydin mailto:[EMAIL PROTECTED] Mittwoch, 16. Januar 2008, 14:56 __ 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.