相关疑难解决方法(0)

将密度线添加到直方图和累积直方图

我想将密度曲线添加到直方图和累积直方图,如下所示:

在此输入图像描述

到目前为止,我可以去:

hist.cum <- function(x, plot=TRUE, ...){
  h <- hist(x, plot=FALSE, ...)
  h$counts <- cumsum(h$counts)
  h$density <- cumsum(h$density)
  h$itensities <- cumsum(h$itensities)
  if(plot)
    plot(h)
  h
}
 x <- rnorm(100, 15, 5)
hist.cum(x)
 hist(x, add=TRUE, col="lightseagreen")

 #
lines (density(x), add = TRUE, col="red")
Run Code Online (Sandbox Code Playgroud)

plot r graph base kernel-density

16
推荐指数
1
解决办法
2万
查看次数

标签 统计

base ×1

graph ×1

kernel-density ×1

plot ×1

r ×1