2016-07-28 101 views
0

如果我有数据集气泡图创建

 Class  Percent Attended   Percent Participated 
     3     .8        .6 
     3     .5        .4 
     2     .9        .5 
     7     .92       .8 

于是就等等,我想创建一个气泡图,其中它显示出席VS百分比参加并通过标记每个类百分比的平均值类

我已经尝试了聚合函数和ggplot函数+点,没有运气

回答

0
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) 

enter image description here

数据

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)) 
+0

一直在寻找更多的散点图的交易类型其中百分比参加了Y轴和百分比出席的是X轴,这些点会被他们从 –

+0

完全类标记。完善 –