2016-12-02 3 views
1

최근 TIMSS report에서 우연히 발견되었습니다. 내 의견으로는 매우 의사 소통하는 음모가 있습니다 (아래 그림 참조). 나는이 플롯을 클리블랜드 점 점이라고 부르는데, 여기에는 신뢰 구간이 추가되어있다. 그것은 ggplot2 또는 matplotlib에서 재현 할 수 있는지 궁금 해서요. 모든 힌트를 환영합니다. plot http://timss2015.org/wp-content/uploads/filebase/science/1.-student-achievement/science-distribution-of-science-achievement-grade-4-table.jpgggplot2의 클리블랜드 도트 플롯

+0

[재현 가능한 예] (http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)를 제공 할 수있는 데이터를 제공해 주실 수 있습니까? –

+0

나는 플롯에 대한 데이터가 [여기]라고 생각합니다 (http://timss2015.org/wp-content/uploads/filebase/science/1.-student-achievement/1_1_science-distribution-of-science-achievement-grade-4. xls) –

답변

2

iris 데이터 세트를 사용 :

library(dplyr) 
library(ggplot2) 

plot_data <- iris %>% 
    group_by(Species) %>% 
    summarise_each(funs(mean, sd, n(), q95=quantile(., 0.95), q75=quantile(., 3/4), q25=quantile(., 1/4), q5 = quantile(., 0.05)), Sepal.Length) %>% 
    mutate(se = sd/sqrt(n), 
     left95 = mean - 2*se, 
     right95 = mean + 2*se) 


ggplot(plot_data, aes(x = Species, y = mean)) + 
    geom_crossbar(aes(ymin = q5, ymax = q95), fill = "aquamarine1", color = "aquamarine1", width = 0.2) + 
    geom_crossbar(aes(ymin = q25, ymax = q75), fill = "aquamarine4", color = "aquamarine4", width = 0.2) + 
    geom_crossbar(aes(ymin = left95, ymax = right95), fill = "black", color = "black", width = 0.2) + 
    coord_flip() + 
    theme_minimal() 

enter image description here

이 당신에게 이러한 목표를 달성하기 위해 ggplot2을 사용하는 방법의 요점을 제공해야합니다. 제공된 데이터는 dplyr 요약없이 쉽게 사용할 수 있습니다.

관련 문제