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. 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) I'm confused. Could you please help me with it? Thank you!
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) > > I'm confused. Could you please help me with it? > > Thank you! > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
I downloaded the 2.3.0 OS X Universal binary off of the Berkeley mirror (found it on the R for Mac OS X link at the bottom of the page). Installation went fine, but when I launch via the GUI it opens the console window and then (after several seconds) quits with no error message. I'm sorry I'm not very proficient with the Terminal, so I don't know if I can use R 2.3.0 with that, or if it's only the GUI startup that's causing the problem. I'm using a G4 Powerbook (PowerPC) laptop with OS X 10.4.6. A universal binary ought to work, right? Or is there something else going on? Just thought I'd let people know... Joran
On Thu, Apr 27, 2006 at 10:48:39AM -0700, nlei at sfu.ca wrote:> 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. > > I'm confused. Could you please help me with it?I was pretty confused by that, too at first. The solution is that freq=False cause hist to plot the DENSITY rather than frequency. And density is not necesssarily the same as relative frequency. Excerpt from ?hist: density: values f^(x[i]), as estimated density values. If 'all(diff(breaks) == 1)', they are the relative frequencies 'counts/n' and in general satisfy sum[i; f^(x[i]) (b[i+1]-b[i])] = 1, where b[i] = 'breaks[i]'. If you want relative distance try something like this: myhist = hist(x,breaks=52, plot=F) myhist$counts = myhist$counts / sum(myhist$counts) plot(myhist,main=NULL,border=TRUE,xlab="days",xlim=c(0,6),lty=2) Not exactly clean, though -- we are messing with the myhist object... cu Philipp -- Dr. Philipp Pagel Tel. +49-8161-71 2131 Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186 Technical University of Munich Science Center Weihenstephan 85350 Freising, Germany and Institute for Bioinformatics / MIPS Tel. +49-89-3187 3675 GSF - National Research Center Fax. +49-89-3187 3585 for Environment and Health Ingolst?dter Landstrasse 1 85764 Neuherberg, Germany http://mips.gsf.de/staff/pagel