Skip to content

Instantly share code, notes, and snippets.

@mikmart
Created September 10, 2018 13:26
Show Gist options
  • Save mikmart/e6d6c374a3793b8c8ddc747adc56828e to your computer and use it in GitHub Desktop.
Save mikmart/e6d6c374a3793b8c8ddc747adc56828e to your computer and use it in GitHub Desktop.
Something weird with geom_bar()
library(tidyverse)

df <- structure(list(foo = structure(c(30L, 15L, 18L, 14L, 50L, 5L, 
20L, 22L, 19L, 9L), .Label = c("01", "02", "03", "04", "05", 
"06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", 
"17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", 
"28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", 
"39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", 
"50", "51"), class = "factor"), bar = structure(c(10L, 8L, 9L, 
3L, 2L, 8L, 9L, 10L, 6L, 1L), .Label = c("01", "02", "03", "04", 
"05", "06", "07", "08", "09", "10", "11"), class = "factor"), 
    n = c(0L, 0L, 0L, 3L, 1L, 4L, 0L, 0L, 0L, 0L)), row.names = c(NA, 
-10L), class = c("tbl_df", "tbl", "data.frame"))

ggplot(df, aes(n, fill = bar)) + geom_bar()
#> Warning: position_stack requires non-overlapping x intervals

Created on 2018-09-10 by the reprex package (v0.2.0.9000).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment