Intro Thoughts
Status Quo
library(tidyverse)
Experiment
tribble(~selection, ~n,
"Candy", 148,
"Toy", 135) %>%
uncount(weights = n) %>%
mutate(group = row_number()) %>%
ggplot() +
aes(x = selection == "Toy", group = group) +
geom_bar(width = .1, color = "black", linewidth = .2)
compute_group_bricks <- function(data, scales){
data %>%
StatCount$compute_group() %>%
mutate(grouping = row_number())
}
StatCount2 <- ggproto("StatCount2", StatCount,
compute_group = compute_group_bricks,
default_aes = aes(group = after_stat(grouping)))
tribble(~selection, ~n,
"Candy", 148,
"Toy", 135) %>%
uncount(weights = n) %>%
ggplot() +
aes(x = selection == "Toy") +
geom_bar(stat = StatCount2, width = .1, color = "black", linewidth = .2)
## Error in `geom_bar()`:
## ! Problem while setting up geom.
## ℹ Error occurred in the 1st layer.
## Caused by error in `compute_geom_1()`:
## ! `geom_bar()` requires the following missing aesthetics: y.