How to plot a density estimate on top of the histogram? [duplicate]

旧街凉风 提交于 2019-12-09 19:00:47

问题


Possible Duplicate:
Fitting a density curve to a histogram in R

x is a NAs free numeric vector.

I run:

> hist(x,density(x), prob=TRUE)

Error Message I get:
Error in rank(x, ties.method = "min", na.last = "keep") : 
  unimplemented type 'list' in 'greater'

It was suggested that I set prob =TRUE when calling hist. If you can explain that as well, it will be great. Thank you.


回答1:


You need to call hist and density separately. Something like this:

hist(x, prob=TRUE)
lines(density(x))


来源:https://stackoverflow.com/questions/12945951/how-to-plot-a-density-estimate-on-top-of-the-histogram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!