ggplot2 icon indicating copy to clipboard operation
ggplot2 copied to clipboard

default_aes not used in compute_*() methods

Open thomasp85 opened this issue 5 years ago • 10 comments

While writing about extensions I noticed that the content of default_aes in a stat is not added to the data before it is passed through the compute_*() mill. This effectively renders it useless for anything but defining mappings for the geom.

The current code reflects this as it has all sorts of code around extracting non-required aesthetics from the data, e.g. in StatBinHex

https://github.com/tidyverse/ggplot2/blob/1223de2d6841be4276b5b398aff747672797c1b9/R/stat-binhex.r#L45-L65

we set a default weight, but still has to guard it with data$weight %||% rep(1L, nrow(data)) when using it in compute_group()

I cannot see any meaningful reason why this is so, and the fix seems obvious. Have I missed an underlying reason @hadley?

thomasp85 avatar Mar 06 '20 08:03 thomasp85