我正在处理一个大型数据集,研究几个地理区域的疾病病例,其中一个预测因素是百里香。我试着创建带有抖动的盒子图,但无法很清楚地解释它。有人能帮上忙吗?
代码如下:
ggplot(factor(Region), Cases, data=orf, geom=c("boxplot", "jitter"),
main=" Cases by Thistles and Regions",fill=factor(Thistles),
xlab="Regions", ylab="Number of cases")这是一个非常大的数据集,所以这里只是一小部分:
Region Thistles Cases
1 1 40
1 2 0
1 1 8
1 3 73
1 3 0
1 1 26
1 2 0
1 1 45
1 4 0
1 4 22
1 0 0
2 3 46
1 0 10
2 1 6
2 1 539
2 1 0
2 2 0
2 1 60
2 1 0
2 1 10
2 3 0
2 3 29
3 2 0
3 4 35
3 3 100
3 2 0
3 1 550
3 2 0
3 3 1
3 5 67
3 1 0
3 2 90

发布于 2015-07-26 04:48:54
这些图表说明了@R RHertel在评论中提出的观点。

library(ggplot2)
p1 = ggplot(iris, aes(x=Species, y=Sepal.Length)) +
geom_point(aes(fill=Species), size=5, shape=21, colour="grey20") +
geom_boxplot(outlier.colour=NA, fill=NA, colour="grey20") +
labs(title="Not Jittered")
p2 = ggplot(iris, aes(x=Species, y=Sepal.Length)) +
geom_point(aes(fill=Species), size=5, shape=21, colour="grey20",
position=position_jitter(width=0.2, height=0.1)) +
geom_boxplot(outlier.colour=NA, fill=NA, colour="grey20") +
labs(title="Jittered")
library(gridExtra)
png("jittering.png", height=5, width=10, units="in", res=100)
grid.arrange(p1, p2, nrow=1)
dev.off()https://stackoverflow.com/questions/31630045
复制相似问题