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

Nick Wray nichol@@@wr@y @ending from ntlworld@com
Fri Aug 31 16:40:55 CEST 2018


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



More information about the R-help mailing list