-
Notifications
You must be signed in to change notification settings - Fork 8
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
Formula processing #197
Formula processing #197
Conversation
…bles from model.frame
…arts x/y/by/facet much more explicitly
Thanks so much for taking this on @zeileis!
This week is tough for me due to work deadlines, but I'll try to take a deeper look over the weekend. |
That's perfectly fine. I'll be on vacation for a bit more than two weeks. So I won't have a lot of time either but should be able to respond to smaller messages. I hope that the new code is also reasonably easy to read and understand. Most of it works fine but I still didn't understand how the |
Hi @zeileis. I finally had some time to review this and everything looks excellent. Thank you! I only have two minor comments and then we can merge:
|
I hope I have correctly incorporated your second point. And regarding the first point: When the number of rows and columns is different, then certain combinations of
But this is messed up because the layout is still 2 x 3 rather than 3 x 2 and hence it is not surprising that the annotation is not correct:
If you have more variables in the |
Ah, I see now. Thanks, let me take a deeper look. Hopefully, the fix won't be too difficult... |
where some levels are missing
Hi @zeileis. I've pushed a few commits directly to your PR—hope that's okay—that seem to have plugged the problem areas. Quick examples... pkgload::load_all("~/Documents/Projects/tinyplot")
#> ℹ Loading tinyplot
tpar(las = 1) This was working beforehand and still does (2 x 3 arrangement): tinyplot(mpg ~ wt, facet = vs ~ gear, data = mtcars) This one wasn't working correctly beforehand, but now does (3 x 2 arrangement)): tinyplot(mpg ~ wt, facet = gear ~ vs, data = mtcars) And here's a more complicated example with multiple variables in the facet formula LHS , which used to trigger an error due to missing values in some facet windows, but now plots everything correctly. tinyplot(mpg ~ wt, facet = gear:vs ~ cyl, data = mtcars, pch = 16, axes = "l", grid = TRUE) Compare against equivalent ggplot2 call: library(ggplot2)
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
facet_grid(vs+gear~cyl, labeller = labeller(.multi_line = FALSE)) +
theme_minimal() Created on 2024-08-18 with reprex v2.1.1 Given that you're on (a well-deserved!) vacation, I imagine that it may be tricky for you to test on your side. But let me know what you think. |
Wonderful, thanks a lot. I'll try to have a look tonight! |
Fixes #205. |
Very nice, thanks for these fixes! I've played around a bit and didn't find anything else. So IMO you can move forward and merge this. Just one comment and one question:
|
Agree with both! The |
Thank you @zeileis! This is great. |
Fixes #191
I started to work on a completely revised formula handling to address the issue above. This is still leaner than employing the
Formula
package but uses a similar approach:tinyformula
explicitly breaks up the formulas into separate formulas forx
,y
(if any),by
(if any), andfacet
(if a formula) plus afull
formula combining all elements (on the right-hand side).tinyframe
to extract the variables from the different formulas from the overall model frame.x
and at most oney
etc.By and large things seem to work. However, I have apparently messed up the two-sided
facet
formulas. Grant @grantmcdermott if you have the time to look at this, this would be great. I'm not sure whether I fully understand how the attributes work...