# [R] relative frequency plot

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Apr 27 20:11:11 CEST 2006

nlei at sfu.ca writes:

> Hi All,
>
> I want to use "hist" to get the relative frequency plot. But the range of
> ylab is greater than 1,which I think it should be less than 1 since it
> stands for the probability.

No, it stands for density, as the y label says. The sum of the areas
of the bars is 1.

Put differently, if you rescale the x axis, the y axis needs
rescaling by the inverse factor.

> Here is my code:
>
> x<-c(1,1,1,0,0,1,1,5,1,1,0,1,1,0,1,0,1,1,0,0,1,1,1,1,1,1,1,1,1,4,1,0,2,1,1,1
> ,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1)
>
> hist(x,breaks=52,main=NULL,freq=FALSE,border=TRUE,xlab="days",xlim=c(0,6),yl
> im=c(0,10),lty=2)
>
>
> But when I tried the other vector,the ylab is less than 1.The code is:
>
> y<-c(6,4,6,6,4,6,5,4,7,5,6,6,8,6,17,9,8,4,6,3,5,8,7,12,5,10,6,4,6,13,7,6,6,2
> 5,4,9,9,6,6,6,6,6,9,4,5,5,4,10,5,7,6)
>
> hist(PLEX2[,2],breaks=52,main=NULL,freq=FALSE,border=TRUE,xlab="days",xlim=c
> (0,30),ylim=c(0,1),lty=2)
>
>
> Thank you!
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help