You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unexpected failure of density plot without any error or warning #3250
I encountered the following example when teaching density plots. If a discrete variable is encoded as numerical (e.g., 0/1), and that variable is mapped onto fill, the variable values get replaced with NA and no fill is applied/no grouping is calculated. Importantly, this happens without any kind of error or warning message, so students get no indication of what they have done wrong, or that something went wrong at all.
It's not immediately clear to me whether and how we can catch this situation, but it would be good if we could. Reprex follows.
Non-unique data columns are silently dropped. We could issue a warning for non-unique missing columns. I just don't know how often such a warning might flag cases that are actually correct.
@thomasp85 Since we're considering cleanup and breaking changes, I would bring up this issue once more, which is an eternal thorn in my side. It comes up every year when I teach ggplot2. I made a draft PR a long time ago that I could revive.
Since all this code does is create a warning, it's not really going to break anything. But, there's the risk of false-positive warnings. The way to avoid false positives is to allow geoms to indicate that the dropped columns were dropped on purpose, and I believe 2-3 geoms in ggplot2 itself would require this modification to avoid spurious warnings.
Yeah, let's revive it and have a look... maybe the best thing is simply to ship the warning and get feedback from users as to when it's a false positive so we can tune it after the fact
Activity
clauswilke commentedon Apr 17, 2019
I believe the problematic code lives here:
ggplot2/R/stat-.r
Lines 109 to 110 in 8359806
Non-unique data columns are silently dropped. We could issue a warning for non-unique missing columns. I just don't know how often such a warning might flag cases that are actually correct.
emit warning if non-constant data columns are dropped. fixes tidyvers…
clauswilke commentedon May 11, 2022
@thomasp85 Since we're considering cleanup and breaking changes, I would bring up this issue once more, which is an eternal thorn in my side. It comes up every year when I teach ggplot2. I made a draft PR a long time ago that I could revive.
Since all this code does is create a warning, it's not really going to break anything. But, there's the risk of false-positive warnings. The way to avoid false positives is to allow geoms to indicate that the dropped columns were dropped on purpose, and I believe 2-3 geoms in ggplot2 itself would require this modification to avoid spurious warnings.
thomasp85 commentedon May 12, 2022
Yeah, let's revive it and have a look... maybe the best thing is simply to ship the warning and get feedback from users as to when it's a false positive so we can tune it after the fact
clauswilke commentedon May 12, 2022
Ok. Will try to get this done next week.
Check for dropped aesthetics and issue a warning if aesthetics are dr…
Check for dropped aesthetics (#4866)