我喜欢stat_ecdf()ggplot2 包的功能部分,我发现它对于探索数据系列非常有用。然而,这只是视觉上的,我想知道是否可行 - 如果是,如何 - 获取关联的表?
请查看以下可重现的示例
p <- ggplot(iris, aes_string(x = "Sepal.Length")) + stat_ecdf() # building of the cumulated chart
p
attributes(p) # chart attributes
p$data # data is iris dataset, not the serie used for displaying the chart
正如 @krfurlong 向我展示的那样这个问题 https://stackoverflow.com/questions/60062217/create-a-table-with-values-from-ecdf-graph, the layer_data
ggplot2 中的函数可以准确地为您提供所需的内容,而无需重新创建数据。
p <- ggplot(iris, aes_string(x = "Sepal.Length")) + stat_ecdf()
p.data <- layer_data(p)
p.data 中的第一列“y”包含 ecdf 值。 “x”是绘图中 x 轴上的 Sepal.Length 值。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)