Skip to content
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

plot2.formula now does proper formula parsing via stats::model.frame #8

Merged
merged 2 commits into from
Apr 9, 2023

Conversation

zeileis
Copy link
Collaborator

@zeileis zeileis commented Apr 8, 2023

To address issue #3, I have implemented now a proper formula parsing for plot2.formula:

  • Internally y ~ x | z is simply converted to y ~ x + z.
  • Then stats::model.frame() is called "as usual" with subset, na.action, and drop.unused.levels.
  • The first variable from the resulting model frame is used as y, the second as x, and all others (if any) are collapsed to a single factor. Either via as.factor() (for a single variable) or interaction() (if more than one variable).
  • Default axis and legend labels are taken from the variable names of the model frame.

Open question: Many arguments of plot2.formula() are actually not used at all in plot2.formula() but only passed on to plot2.default(). If these arguments have defaults that are identical between the two methods, the argument could also be omitted from plot2.formula(). If needed it is passed through ....

@grantmcdermott
Copy link
Owner

Excellent, thanks @zeileis!

Do you mind quickly adding yourself as contributor in the DESCRIPTION file? We can merge directly after.

RE: "Unused" arguments in plot2.formula. You're quite right. I think that's just a vestige of my original script —before I packaged it up—where the formula implementation was the sole default without any method dispatch. We can change it as part of this PR or separately. Up to you.

@grantmcdermott
Copy link
Owner

Had a chance to update the DESCRIPTION file. Let's take the argument passing separately.

@grantmcdermott grantmcdermott merged commit aea11c6 into main Apr 9, 2023
5 checks passed
@grantmcdermott grantmcdermott deleted the formula-parsing branch January 18, 2024 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants