r - Histogram with density line -
i want plot histogram density line. code below not work. thought why?
control <- c(4.17,3.05,5.18,4.01,6.11,4.1,5.17,3.57,5.33,5.59, 4.66,5.58,3.66,4.50,3.90,4.61,5.62,4.53,6.05,5.14) hist(control,col="gray",xlab="utility",prob=true, main="histogram of individual utilities") curve(dnorm(control,mean=mean(control), sd=sd(control)), add=true,col="red")
what error message? should have told us. get:
error in curve(dnorm(control, mean = mean(control), sd = sd(control)), : 'expr' must function, or phone call or look containing 'x'
so create look containing x
:
curve(dnorm(x,mean=mean(control),sd=sd(control)), add=true,col="red")
r line histogram
No comments:
Post a Comment