COMTE Guillaume
2006-Aug-16 15:34 UTC
[R] Strange behavior with "hist" function filled with breaks and freq attribute
Hy all,
I give example code :
connexions_jours<-c(1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,6,6,7,7,7,7,7,7,7,7,8,8,8,12,15,19)
pas_de_groupe<-1
hist(connexions_jours,col="red",xlab="Répartition du nombre de
connexions par jours (sans
break)",main="",ylab="",freq=FALSE)
hist(connexions_jours,breaks=(max(connexions_jours)/pas_de_groupe),col="red",xlab="Répartition
du nombre de connexions par
jours",main="",ylab="",freq=FALSE)
pas_de_groupe<-5
hist(connexions_jours,breaks=(max(connexions_jours)/pas_de_groupe),col="red",xlab="Répartition
du nombre de connexions par
jours",main="",ylab="",freq=FALSE)
As in the R help for ?hist i have :
freq: logical; if 'TRUE', the histogram graphic is a representation
of frequencies, the 'counts' component of the result; if
'FALSE', _relative_ frequencies ("probabilities"),
component
'density', are plotted. Defaults to 'TRUE' _iff_
'breaks'
are equidistant (and 'probability' is not specified).
So i'm plotting 3 graphs of probabilities, but because of the breaks the « y
» values seems to be broken as if i have to multiplicate the values shown by the
break range to have the real percent.
So i'm wondering why it doesn't show the sum of the probability instead
of the average for each values grouped.
Did someone see where i'm wrong?
I'll have a look to barplot, to see if it can handle it, but i still find
that strange for hist...
Thks all
COMTE Guillaume
[[alternative HTML version deleted]]
