I'm trying to create a density plot and add it a normal curve.
histvb <- hist(color$VB,
probability=TRUE,
breaks=seq(4000, 16000, by=1000),
main=NULL,xlab=c("Visible Brigthness"),
ylab=("Probability Densities"),cex.lab=1.2)
vb<-color$VB
xfit<-seq(min(0),max(16000),length=16000)
yfit<-dnorm(xfit,mean=mean(vb),sd=sd(vb))
yfit<-yfit*diff(hist$mids[1:2])*length(vb)
lines(xfit, yfit, col="blue",lty=5, lwd=2)
When I run these lines, I get the plot with the line and everything seems ok, but I also get this message
yfit <- yfit*diff(hist$mids[1:2])*length(vb)
Error in hist$mids : object of type 'closure' is not subsettable
I'm concerning about this error message since I don't know what it means..