[R] how to overlay two histograms
Ana Marija
@okov|c@@n@m@r|j@ @end|ng |rom gm@||@com
Fri Sep 18 00:01:20 CEST 2020
Hello,
I am trying to overlay two histograms with this:
p <- ggplot(d, aes(CHR, counts, fill = name)) + geom_bar(position = "dodge")
p
but I am getting this error:
Error: stat_count() can only have an x or y aesthetic.
Run `rlang::last_error()` to see where the error occurred.
my data is this:
> d
CHR counts name
1 1 193554 old
2 2 220816 old
3 3 174350 old
4 4 163112 old
5 5 168125 old
6 6 182366 old
7 7 143023 old
8 8 147410 old
9 9 122112 old
10 10 138394 old
11 11 130069 old
12 12 124850 old
13 13 104119 old
14 14 83931 old
15 15 72287 old
16 16 71550 old
17 17 58380 old
18 18 76812 old
19 19 37040 old
20 20 63407 old
21 21 33863 old
22 22 33812 old
23 1 202783 new
24 2 252124 new
25 3 213337 new
26 4 201001 new
27 5 207606 new
28 6 228133 new
29 7 147218 new
30 8 177518 new
31 9 121276 new
32 10 163447 new
33 11 158724 new
34 12 142183 new
35 13 111189 new
36 14 83043 new
37 15 61063 new
38 16 55439 new
39 17 32883 new
40 18 69135 new
41 19 16624 new
42 20 48541 new
43 21 25479 new
44 22 19698 new
Basically I need to show counts per CHR in "old" and "new" side by side.
Please advise,
Ana
More information about the R-help
mailing list