如何在直方图上方绘制密度估计? [英] How to plot a density estimate on top of the histogram?

查看:251
本文介绍了如何在直方图上方绘制密度估计?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
在R中将密度曲线拟合为直方图

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

x是无NA的数值向量.

x is a NAs free numeric vector.

我跑步:

> 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'

建议在调用hist时将prob设置为TRUE.如果您也能解释这一点,那将是很棒的.谢谢.

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

推荐答案

您需要分别调用histdensity.像这样:

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

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

这篇关于如何在直方图上方绘制密度估计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆