Re: [R] how to overlay two histograms

2020-09-18 Thread John Kane
Is this what you want? ggplot(d, aes(counts, fill = name)) + geom_bar(stat = "bin", position = "dodge") Note: You probably should play around with the "bin" width. On Thu, 17 Sep 2020 at 18:05, Ana Marija wrote: > Hello, > > I am trying to overlay two histograms with this: > > p <- ggplo

Re: [R] how to overlay two histograms

2020-09-17 Thread Ana Marija
HI Jim, fantastic solution! Thank you so much!!! Ana On Thu, Sep 17, 2020 at 6:01 PM Jim Lemon wrote: > > Hi Ana, > Sorry it's not in ggplot, but it may help: > > d<-read.table(text="CHR counts name > 1 193554 old > 2 220816 old > 3 174350 old > 4 163112 old > 5 168125 old > 6

Re: [R] how to overlay two histograms

2020-09-17 Thread Rasmus Liland
On 2020-09-17 17:01 -0500, Ana Marija wrote: > 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::

Re: [R] how to overlay two histograms

2020-09-17 Thread Jim Lemon
Hi Ana, Sorry it's not in ggplot, but it may help: d<-read.table(text="CHR counts name 1 193554 old 2 220816 old 3 174350 old 4 163112 old 5 168125 old 6 182366 old 7 143023 old 8 147410 old 9 122112 old 10 138394 old 11 130069 old 12 124850 old 13 104119 old 14

[R] how to overlay two histograms

2020-09-17 Thread Ana Marija
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: