首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ggpmisc::stat_poly_eq()不考虑按变量加权

ggpmisc::stat_poly_eq()不考虑按变量加权
EN

Stack Overflow用户
提问于 2018-04-03 15:49:27
回答 1查看 372关注 0票数 1

如何使ggpmisc::stat_poly_eq()考虑到变量的权重?在文档中,我没有看到像geom_smooth中存在的那样包含权重的参数,如果我试图在aes()中强制它,就会导致‘警告:忽略未知的参数:权重’。我知道打印正确公式的其他解决方案,如这里所示,但是在stat_poly_eq()中使用它会更干净。有人发现了吗还是我漏掉了什么?谢谢大家。

代码语言:javascript
复制
stuff<-structure(list(var = 2:31, mean = c(17026.5, 11028.6842105263, 
                                13113.1111111111, 11087.3679395386, 9863.8664212548, 10060.676012167, 
                                9378.01091924399, 9790.67922990444, 8569.95788246269, 8839.68511390887, 
                                7656.50625471556, 7370.78564257028, 7939.13425925926, 7541.83192090395, 
                                8845.67474747475, 8023.03099415205, 6373.05976190476, 6337.93259803922, 
                                6824.79901960784, 7450.80769230769, 6651.81884057971, 5548.59722222222, 
                                7802.78205128205, 3627.07407407407, 2471, 2248.33333333333, 1368.7, 
                                2104.25, 742, 2097.5), n = c(2L, 19L, 150L, 419L, 1562L, 3178L, 
                                                             3880L, 2965L, 4288L, 2780L, 2209L, 664L, 54L, 59L, 66L, 57L, 
                                                             50L, 34L, 34L, 26L, 23L, 18L, 13L, 9L, 7L, 7L, 5L, 2L, 4L, 2L
                                )), .Names = c("var", "mean", "n"), row.names = c(NA, -30L), class = "data.frame")


ggplot(data=stuff, aes(x=var, y=mean))+
geom_point()+
geom_smooth(aes(weight=n), method='lm', formula = y~x)+
stat_poly_eq(aes(label=paste(..eq.label.., ..rr.label.., sep="~~~")),
           formula=y~x, label.x.npc=0.8, label.y.npc=0.8,
           coef.digits=3, parse=TRUE)

填充数据中的数字

代码语言:javascript
复制
#currently, the equation printed in the plot does not correspond to the coefficients resulting with weigth=n

truecoeff<-lm(data=stuff, mean~var, weight=n)

truecoeff
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-30 08:52:40

谢谢你的报道!我创造了你的信息中的一个问题。这在2018-07-31之前提交给CRAN的开发版本中已经固定为'ggpmisc‘0.3.0。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49634241

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档