2016-07-28 219 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

完全類標記。完善 –