Skip to content

Dealing with y1/y2 ~ x formulas#341

Merged
grantmcdermott merged 1 commit intomainfrom
formula-processing
Mar 17, 2025
Merged

Dealing with y1/y2 ~ x formulas#341
grantmcdermott merged 1 commit intomainfrom
formula-processing

Conversation

@zeileis
Copy link
Copy Markdown
Collaborator

@zeileis zeileis commented Mar 17, 2025

Fixes #339

After the discussion in the issue, I tried to address this with two improvements:

  1. Explicit pointer to I() in the warning message.
  2. More details in the documentation of the formula argument.

Example for 1:

tinyplot(mpg/hp ~ wt, data = mtcars)
## Warning message:
## In tinyplot.formula(mpg/hp ~ wt, data = mtcars) :
##   formula should specify at most one y-variable, using: mpg
## if you want to use arithmetic operators, make sure to wrap them inside I()

From the ?tinyplot documentation for argument formula:

a formula that optionally includes grouping variable(s) after a vertical bar, e.g. y ~ x | z. One-sided formulae are also permitted, e.g. ~ y | z. Only a single y and x variable (if any) must be specified but multiple grouping variables can be included in different ways, e.g. y ~ x | z1:z2 or y ~ x | z1 + z2. (These two representations are treated as equivalent; both are parsed as interaction(z1, z2) internally.) If arithmetic operators are used for transforming variables, they should be wrapped in I(), e.g., I(y1/y2) ~ x. Note that the formula and x arguments should not be specified in the same call.

… I()), extend formula documentation in ?tinyplot
Copy link
Copy Markdown
Owner

@grantmcdermott grantmcdermott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@grantmcdermott grantmcdermott merged commit d46321c into main Mar 17, 2025
3 checks passed
@grantmcdermott grantmcdermott deleted the formula-processing branch March 17, 2025 15:17
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.

Dealing with formula

2 participants