-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Handle NA gracefully in geom_sf #3546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this in principle. A few comments:
-
Could you link to the original bug report in one of the commit messages: Regression: geom_sf() is now too aggressive in removing rows #3536
-
Should we add a visual regression test for polygons with
NA
line color?
@@ -107,6 +100,10 @@ remove_missing <- function(df, na.rm = FALSE, vars = names(df), name = "", | |||
|
|||
df | |||
} | |||
detect_missing <- function(df, vars, finite = FALSE) { | |||
vars <- intersect(vars, names(df)) | |||
!cases(df[, vars, drop = FALSE], if (finite) is_finite else is_complete) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this line correct? Where does is_complete
come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a function defined in utilitites.r
. detect_missing()
is more or less lifted from remove_missing()
so that sf_grobs()
can use the same logic as handle_na()
NEWS.md
Outdated
@@ -1,5 +1,7 @@ | |||
# ggplot2 (development version) | |||
|
|||
* `geom_sf()` now removes rows can't be plotted due to `NA` aesthetics (#3546, @thomasp85) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"removes rows that can't be plotted"
Could you also verify that the example from #3483 still works? |
It is linked at the top of the PR. Why would you want it in a commit message (that will get squashed away during merge)?
I've done that already (but forgot to mention). Do you want a repress of it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Sorry for commenting this late...
One minor problem of this approach to move the process to outside of
(https://travis-ci.org/tidyverse/ggplot2/jobs/591938837#L1219-L1227) |
Co-Authored-By: Hiroaki Yutani <yutani.ini@gmail.com>
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Fixes #3536
This is an alternative implementation to the fix in #3537 that respects the different geometry types interpretation of NA. As the problem of NA's is unique to the vectorised constructors there is no need to handle geometrycollections in any special way as they will always be treated as scalars and grid accepts a single NA in
gpar()
Created on 2019-10-01 by the reprex package (v0.2.1)