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
Bug in geom_sf()? Unable to convert call to string when processing geometry aesthetic at print. #4122
An example similar to p2 is used in the {ggformula} package but is now breaking. It appears that when rendering the plot, as_string(as_name()) fails on the geometry aesthetic when it has the form data$variable. Simply storing the variable as a vector "solves" the problem; see p1.
# this failsp2<-
ggplot(ggformula::MIpop %>% arrange(county)) +
geom_sf(aes(fill= log10(population), geometry=MI$geometry), color="white")
p2#> Error: Can't convert a call to a string
ggformula examples
For completeness, here are the {ggformula} examples that led to this. I see that these are not quite identical (although the same issues arise). See the geometry aesthetics displayed near the end.
p3 <- gf_sf(
data = MIpop %>% dplyr::arrange(county),
fill = ~ log10(population),
geometry = ~ MIgeom, color = "white")
p3
p4<- gf_sf(
data=MIpop %>% dplyr::arrange(county),
fill=~ log10(population),
geometry=~MI$geom, color="white")
p4#> Error: Can't convert a call to a string
None of these examples are idiomatic, so I'd say ggformula should change its examples. Below I demonstrate idiomatic use for both ggplot2 and ggformula.
I realize there are other ways to do things, but it seems like these things should work. It works fine for things like geom_point(), for example, and it worked until recently in geom_sf() as well. (That ggformula example has been in the ggformula package for quite some time and passed CRAN checks in March.) So I would say that geom_sf() behavior is unexpected, and I wonder if it is also unintended -- perhaps a side effect of rlang changes?
Activity
clauswilke commentedon Jul 8, 2020
None of these examples are idiomatic, so I'd say ggformula should change its examples. Below I demonstrate idiomatic use for both ggplot2 and ggformula.
Created on 2020-07-07 by the reprex package (v0.3.0)
yutannihilation commentedon Jul 8, 2020
I agree specifying a vector in
aes()is not a recommended usage. That said, I feel this should work.rpruim commentedon Jul 8, 2020
Thanks for the quick reply.
I realize there are other ways to do things, but it seems like these things should work. It works fine for things like
geom_point(),for example, and it worked until recently ingeom_sf()as well. (That ggformula example has been in the ggformula package for quite some time and passed CRAN checks in March.) So I would say thatgeom_sf()behavior is unexpected, and I wonder if it is also unintended -- perhaps a side effect of rlang changes?Created on 2020-07-08 by the reprex package (v0.3.0)
yutannihilation commentedon Jul 8, 2020
Again, while it works, it's not a recommended usage.
Handle when `geometry` is not a symbol (#4127)