创建并排条形图

时间:2017-04-24 15:24:14

标签: r rstudio

      time pctremembered
1  evening            no
2  evening            no
3  evening           yes
4  evening           yes
5  evening            no
6  evening           yes
7  evening            no
8  evening           yes
9  morning           yes
10 evening            no
11 evening           yes
12 evening           yes
13 evening            no
14 evening            no
15 morning            no
16 morning            no
17 morning            no
18 morning           yes
19 morning            no
20 morning            no
21 morning            no
22 evening           yes
23 evening           yes
24 evening            no
25 evening           yes
26 evening            no
27 evening           yes
28 morning            no
29 evening           yes
30 evening           yes
31 evening           yes
32 evening            no
33 evening            no
34 evening           yes
35 evening            no
36 morning            no
37 morning            no
38 morning            no
39 morning           yes
40 evening            no
41 evening            no
42 evening            no
43 evening            no
44 evening            no
45 evening            no
46 evening            no
47 evening            no
48 evening           yes
49 evening            no
50 morning            no
51 morning           yes
52 morning           yes
53 morning            no
54 morning           yes
55 morning           yes
56 evening           yes
57 evening            no
58 evening           yes
59 evening           yes
60 evening            no
61 evening           yes
62 evening            no
63 evening            no
64 evening           yes
65 evening           yes
66 evening            no
67 evening            no
68 morning            no
69 morning            no
70 morning           yes
71 morning            no
72 morning            no
73 morning            no
74 morning            no
75 morning            no
76 evening            no
77 evening           yes
78 evening            no
79 evening           yes
80 evening            no
81 evening            no

如何在Rstudio上使用此并排条形图?我感到很困惑。能帮我一步一步给你帮忙吗? 谢谢, Alanna

1 个答案:

答案 0 :(得分:1)

使用基本方法的Barplot:

pip install scikit-image

enter image description here

使用ggplot方法绘制Barplot:

counts <- table(df$pctremembered, df$time)
barplot(counts, col=c("darkblue","red"), legend = rownames(counts), beside=T)

enter image description here