Re: [R] smooth line overlap with histogram

2010-05-06 Thread Thomas Stewart
Try x<-rowMeans(matrix((rbinom(1000,4,.45)-4*.45)/sqrt(.45*.55/4),ncol=10)) hist(x,freq=F,ylim=c(0,.5)) ### The key is the freq=F option. curve(dnorm(x),add=T) ### You can use curve to plot a function lines(density(x)) ### Or density for a kernel density estimate. -tgs On Thu, May 6, 2010

Re: [R] smooth line overlap with histogram

2010-05-06 Thread Ruihong Huang
Hi, I don't quite understand what you want. But perhaps, you would like to try this hist(datobs) lines(density(datobs)) and get some ideas Best, Ruihong On 05/07/2010 02:42 AM, Roslina Zakaria wrote: > Hi r-users, > > I would like to overlap a smooth line on the histogram. I tried using s

[R] smooth line overlap with histogram

2010-05-06 Thread Roslina Zakaria
Hi r-users,   I would like to overlap a smooth line on the histogram.  I tried using spline but it does not work. sq <- seq(0,900,by=50) sq.50  <- as.character(sq) datobs <- sum_pos ## first, plot histogram histo <- hist(datobs,breaks=sq,freq=F) ## extract counts from histogram and calculate