gpt4 book ai didi

r - 错误: Found object is not a stat

转载 作者:行者123 更新时间:2023-12-01 22:07:51 26 4
gpt4 key购买 nike

我使用以下代码:

library (ggplot2)
df=data.frame(score=c(1,3,5,9,7,8,4,1,2,6,1,6,2,1,3,1,3,5,8,4),
age=c(2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3))

ggplot(data=df,aes(x=age,y=score))+
geom_point(position=position_jitter(width=.1),aes(color=age))+
geom_line(stat = "hline", yintercept = "mean",aes(group=age))+
stat_summary(geom = "line", fun.y="mean",aes(yend=..y..),width=.5)+
stat_summary(fun.data="mean_cl_boot",geom="errorbar",width=.5)+
theme_classic()

但我收到此错误:

Error: Found object is not a stat.

有谁知道这个问题怎么解决吗?我以前用过这个,但现在不起作用。我想制作这样的东西:

enter image description here

我想要平均条,但我只能产生这样的东西:

enter image description here

最佳答案

您可以使用 stat_summary 与错误栏几何对象并通过特殊变量将 yminymax 设置为汇总统计量来获得相同的结果..y...

ggplot(df, aes(x = age, y = score)) + 
geom_point(position = position_jitter(width = .2), aes(color = age)) +
stat_summary(fun.data = "mean_cl_boot", geom = "errorbar", width = .5) +
stat_summary(geom = "errorbar", fun.y = mean, aes(ymin = ..y.., ymax = ..y..))

关于r - 错误: Found object is not a stat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42820438/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com