r - 一种方式-R中的Anova图与CI
问题描述
我进行了单向方差分析
mydat=structure(list(Price = c(1480000L, 1480000L, 1035000L, 1480000L,
1465000L, 689000L, 611000L, 611000L, NA, 855000L, 855000L, NA,
1480000L, 1035000L, NA, 1465000L, 850000L), Regionname = structure(c(2L,
2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L
), .Label = c("Eastern Victoria", "Northern Metropolitan"), class = "factor")), .Names = c("Price",
"Regionname"), class = "data.frame", row.names = c(NA, -17L))
现在我尝试创建情节
require(ggplot2)
ggplot(mydat, aes(x = Regionname, y = Price)) +
geom_boxplot(fill = "grey80", colour = "blue") +
scale_x_discrete() + xlab("Regionname") +
ylab("Price")
但我对这个可视化完全不满意
如何在这张照片上获得情节
解决方案
那这个呢?
# make a simple regression first
s1 <- summary(lm(Price ~ Regionname + 0, mydat)) # note: w/o constant!
# of which you can create a model frame
m1 <- data.frame(coef=coef(s1)[1, 1], se=coef(s1)[1, 2], mn="Eastern Victoria")
m2 <- data.frame(coef=coef(s1)[2, 1], se=coef(s1)[2, 2], mn="Northern Metropolitan")
mf <- rbind(m1, m2)
i95 <- - qnorm((1 - .95) / 2) # significance 95%
library(ggplot2)
ggplot(mf, aes(color=mn)) +
geom_pointrange(aes(x=mn, y=coef, ymin=coef - se*i95, ymax=coef + se*i95), shape=0) +
geom_errorbar(aes(x=mn, ymin=coef - se*i95, ymax=coef + se*i95), width=.2) +
geom_line(aes(y=coef, x=mn, group=1)) +
scale_color_manual(values=rep("dark red", 2)) +
labs(x="Regionname", y="Price") +
guides(color=FALSE) +
theme_bw()
产量
推荐阅读
- delphi - 有没有办法在 Delphi 中围绕其图片塑造一个按钮
- python-3.x - 更改 dict 中的值,更改原始返回 dict 的值
- spring - 石英调度程序类的 Kotlin Spring Boot Autowired lateinit 问题
- fortran - Fortran 在 for 循环中对日志进行矢量化
- botframework - Bot Framework V4 上的对话继续问题
- reactjs - React 中的 Apollo 客户端和 graphQl 的 cookie 身份验证如何工作
- json - 从 API 检索时出现 JSON 响应错误 NSSingleObjectArray
- dart - 如何在 Dart 的循环中更改对象值
- python - 在 docker 中使用 Python web-server 使用 ML 模型回答 post 请求
- rust - 更新/重新初始化在lazy_static中定义的变量