Consult the docs, please. ?hist and the "breaks" argument. Also note the "freq" argument, which means you should not be computing relative frequencies manually.
Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Aug 31, 2018 at 7:42 AM Nick Wray via R-help <r-help@r-project.org> wrote: > Hello again. I am trying to alter the bin size on a histogram where I > have reset the vertical axis to relative frequency, rather than absolute. > Beneath is a simple example (not my real data) of this: > > xvals<-rnorm(1000,0,1) > xvals > hist(xvals) > h<-hist(xvals,plot=F) > > h > h$counts > h$counts<-h$counts/sum(h$counts) > h$counts > plot(h,freq=T,ylab="Relative Frequency") > > > This gives me a plot with bin sizes of 0.5 and the relative frequency, but > I cannot reset the bin size as well. I don't know whether the only way to > do it is to reset all the h$mids etc as well but this seems horrendously > complicated and I wonder whether I am missing something simple > > Any ideas I would be thankful for Nick Wray > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.