r - 使用 ggplot2 stat_ecdf 在 R 中创建经验分布函数
问题描述
我正在尝试为经验分布函数制作 ggplot 图,stat_ecdf
但出现以下错误。有关如何解决此问题的任何帮助?这d
是一个double
清单。
library(ggplot2)
>> d
[1] 9.126560 8.837303 6.942810 9.515659 7.614937 9.190298 6.866715 6.322031
[9] 8.846318 7.181234 9.104691 7.187005 7.371961 7.180689 9.117338 9.174383
[17] 7.209469 9.030088 9.519537 8.987137 7.044774 7.566912 6.845430 9.370125
>> typeof(d)
[1] "double"
>> ggplot(data.frame(d), aes(expression)) + stat_ecdf(geom = "point")
Don't know how to automatically pick scale for object of type function. Defaulting to continuous.
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, :
arguments imply differing number of rows: 0, 24
解决方案
aes
需要包含x
.
ggplot(data.frame(x = d), aes(x)) + stat_ecdf(geom = "point")
推荐阅读
- go - gRPC 可以集成到 Flutter-web 中吗?
- r - 在 R 中,是什么使 NULL 原子化,因此不能存在于向量中?
- reactjs - 使用字符串动态响应 setState
- javascript - javascript迭代器中的递增计数器
- kubernetes - 如何在 Kubernetes 中找到服务的 url?
- tensorflow - TensorFlow-gpu 似乎没有看到我的 gpu
- flutter - 如何在水平滚动视图中显示所有日期
- python - 如何在 lambda 表达式中保持某些参数不变
- android - 唤醒 Android 通话
- reactjs - 尝试使用此 axios/typescript 实现初始化和设置组件状态的问题