[R] Resetting bin size in histogram having already changed to relative frequencies

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Fri Aug 31 16:48:52 CEST 2018


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 using 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 using 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]]




More information about the R-help mailing list