如果我有数据集
Class Percent Attended Percent Participated
3 .8 .6
3 .5 .4
2 .9 .5
7 .92 .8因此,等等,我试图创建一个气泡图,它显示了每个班级的平均百分比和参与的百分比,并由类标记。
我尝试了聚合函数和ggplot函数,但是没有运气。
发布于 2016-07-28 19:04:24
library(ggplot2)
library(dplyr)
df1 <- df %>% group_by(Class) %>% summarise_all(funs(mean))
ggplot(df1, aes(x = Percent_Attended, y = Percent_Participated)) +
geom_point(aes(color = factor(Class)), size = 3)

数据
structure(list(Class = c(3L, 3L, 2L, 7L), Percent_Attended = c(0.8,
0.5, 0.9, 0.92), Percent_Participated = c(0.6, 0.4, 0.5, 0.8)), .Names = c("Class",
"Percent_Attended", "Percent_Participated"), class = "data.frame", row.names = c(NA,
-4L))https://stackoverflow.com/questions/38643702
复制相似问题