如何制作海盗情节?

时间:2018-04-14 18:45:35

标签: r

我最近提交了一份手稿,审稿人要求提供我的数据的海盗情节。我有两组"年轻"和"年龄"我测量过大脑反应幅度的个体。我花了3个小时来学习如何将我的csv数据加载到R中!但现在,我真的不知道如何使用函数制作海盗情节。第一列是年龄,第二列是年龄组(年轻,年老),第四列是大脑反应的幅度。有62行(个人)是否有人可以帮我制作海盗情节以显示年轻人和老年人群体之间的差异?

age ageGroup gender        MMNamplitude   ampLLRdevNEW
24 Young female -2.6748016 -1.61673200 
30 Young female -3.5406852 -4.43758060 
24 Young female -4.7248983 -1.13789930 
25 Young male -2.0330820 -1.20710680
24 Young male -3.1502962 -1.34792170
22 Young male -2.1730402 -2.18172410
22 Young male -1.0114062 -0.81161368
25 Young female -3.6766238 -2.80001140
23 Young female -2.7683165 -0.22415800
31 Young male -3.8966408 -2.70333150
25 Young male -3.1112120 -1.40961360
31 Young female -3.3528483 -3.71767590
26 Young female -0.4627196 0.64751029
24 Young female -2.1004868 0.25361124
21 Young female -3.2049625 -0.75276893
26 Young female -2.1916404 -0.53311187
24 Young female -5.1361308 -0.79336965
24 Young male -3.0489032 -2.04726050
19 Young male -3.5671501 -1.73471670
23 Young male -4.1360154 -4.67426160
22 Young male -2.2351420 1.53577610
19 Young male -4.4592948 -2.31338240
30 Young female -3.2692153 -2.00995450
24 Young male -1.4944552 -0.07673313
20 Young male -2.0538952 -1.10110350
20 Young male -2.6905904 -0.90252703
28 Young female -4.0401025 -2.06789450
26 Young female -1.6229513 -0.29561293
NA Young male -7.3316092 -4.88589050 
30  Young female -3.5574262 -1.96863960 
31 Young female -3.6331723 -5.46660800 
NA Young female -0.4863969 1.42703760
28 Young female -1.1213547 -1.84548260
65 old male -4.2015524 -6.87044380
60 old female -1.2958775 -1.33513150 
60 old female 0.3597395 -0.53502542
73 old female -1.6942397 -2.78447790
66 old male -0.7753630 -2.01488880
71 old male -1.4117705 -1.55971790
69 old female -2.6966374 -2.78534790
NA old female -2.7576666 -2.37085100
62 old male -1.3446590 -0.81808186 
61 old female -1.1353959 -1.20741810 
72 old male -3.3344913 -4.53399660
62 old male -2.9870763 -2.88575740
63 old female -1.7782377 -0.76250124
63 old female -2.6238792 -3.47005030
70 old female -2.8348722 -3.30441830
74 old male -1.2044405 -2.07105450
77 old male -2.4079964 -4.68829200
67 old female -2.9031038 -3.94690870
73 old male -3.7105155 -5.47033310
60 old male -4.1027393 -5.74142500
65 old male -3.3070505 -4.65865180
63 old female -2.5611329 -3.69858570
62 old female -2.6453319 -2.59949870
66 old female -1.7583463 -1.93183160
61 old male -2.3662858 -2.03517960
70 old male -3.7941179 -4.71021510
65 old female -2.4184918 -2.20737310
64 old male -1.9983604 -3.55956150
NA old male -2.4147241 -3.96302600

1 个答案:

答案 0 :(得分:2)

试试这个

# first install needed packages
install.packages('tidyverse')  # for data manipulation, visualization, etc.
install.packages('devtools')   # needed to install ggpirate
devtools::install_github("mikabr/ggpirate") # pirate plot

然后加载包

library(tidyverse)
library(ggpirate)

如果您的数据被调用df,请执行:

df %>%
  ggplot(aes(ageGroup, MMNamplitude)) +
  geom_pirate(aes(color=ageGroup), show.legend = TRUE) +
  facet_wrap(~gender)

您不需要上一个facet_wrap,只是为了向您展示分割数据是否可行。

输出

enter image description here

我使用了您的数据子集,因此您的输出可能看起来不同。