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::last_error()` to see where the error occurred.

Dear Ana,

you need to specify stat="identity" [1], 
like so:

        mapping <- ggplot2::aes(
          x=CHR,
          y=counts,
          fill=name)
        p <-
          ggplot2::ggplot() +
          ggplot2::geom_bar(
            data=d,
            mapping = mapping,
            position="dodge",
            stat="identity")

Best,
Rasmus

[1] 
https://stackoverflow.com/questions/61068031/error-stat-count-can-only-have-an-x-or-y-aesthetic

Attachment: signature.asc
Description: PGP signature

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to