-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Cant make use of tidy context in scale_x/y_ #5314
Comments
You can make use of the data piped into ggplot2 if you use curly braces and insert library(tidyverse)
mtcars %>% filter(cyl > 4) %>% {
ggplot(., aes(x = mpg, y = qsec)) + geom_point() +
geom_vline(xintercept = max(.$mpg))
} The facet syntax is as clunky as it is due to historical choices. It seems it can't be improved without breaking a lot of people's plotting code. |
Oh that's something I wasnt aware of. putting curly bracets outside of the entire plot. thanks |
I realised this issue had been discussed in the past in for example #3268 and was decided against, so I'm going to close this issue for the same reason (requiring a breaking rewrite). |
One last thing. the {} method works only with magritrr pipes (%>%) but not the base-R pipes (|>). Is it worth to ask to include base r pipes as well to work with this method? I switched to use them automatically with Ctrl + Shift + M |
Hello. I want to point out three ggplot-related issues that dont correspond with the tidy-philosophy:
1 + 2: Cant make use of modified data
This code doesn't work (error below). In both cases I think there could be a recognition, even without the
.data$
that I am refering in a tidy way to my already assigned data (that is, a filtered mtcars)Why can't we simply pass the data frame (after we modified it for ggplot) as an argument and have R recognizing the variables in a tidy fashion?
3: facet_wrap could be wayyy simpler
This is more of an improvement suggestion, when implementing facets, I would expect R to recognize the columns in my dataset, and offering them to me on top of the different args the function can take.
The '~' or using
vars()
is really redundent, the use-case of most users (all?) is very simple. to use a grouping feature to divide the plots.I hope my issues are clear :)
The text was updated successfully, but these errors were encountered: