Hello R-list, I've been using hist to plot histograms of some data, but I get variable numbers of bins. I understood from reading the help file that breaks will set the number of bins. Please correct me if I'm wrong. I'm plotting measures from subsets of a larger data set. Depending on the data subset the number of bins varies despite having set breaks to 5 in all cases. See commands below. (BTW I'm using R1.2.2 on SunSolaris) Thanks, David hist(allvariances[allvariances$type %in% "ku",3], breaks=5, main="ku variance histogram") par(new=FALSE) hist(allvariances[allvariances$type %in% "ki",3], breaks=5, main="ki variance histogram") par(new=FALSE) hist(allvariances[allvariances$type %in% "tu",3], breaks=5, main="tu variance histogram") par(new=FALSE) hist(allvariances[allvariances$type %in% "ti",3], breaks=5, main="ti variance histogram") S. David White sdavidwhite at bigfoot.com Columbus, Ohio -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi> I've been using hist to plot histograms of some data, but I get variable > numbers of bins. I understood from reading the help file that breaks will > set the number of bins. Please correct me if I'm wrong. > I'm plotting measures from subsets of a larger data set. Depending on the > data subset the number of bins varies despite having set breaks to 5 in > all cases.The crucial part of the help is the word "approximate" ... breaks: either a single number giving the approximate number of cells for the histogram or a vector giving the breakpoints between histogram cells. ... R takes your suggestion for the number of bins and modifies it if necessary to produce a "nice" number of bins. You can have exact control over the number of bins if you give the bin breaks. For example, compare ... par(mfrow=c(2,2)) for (i in 1:4) hist(rnorm(50), breaks=4) # sometimes 6 bins, sometimes 5 bins, ... ... with ... par(mfrow=c(2,2)) for (i in 1:4) hist(rnorm(50), breaks=c(-4,-2,0,2,4)) # always 4 bins Hope that helps Paul -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._