Skip to content

Conversation

@simonpcouch
Copy link
Contributor

This is the first step to address #1003.

form_a <- mpg ~ .
form_b <- ~ .

# [[2]] does not necessarily give LHS
form_a[[2]]
#> mpg
form_b[[2]]
#> .

# resulting in:
rlang::eval_tidy(form_a[[2]], mtcars)
#>  [1] 21.0 21.0 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 17.8 16.4 17.3 15.2 10.4
#> [16] 10.4 14.7 32.4 30.4 33.9 21.5 15.5 15.2 13.3 19.2 27.3 26.0 30.4 15.8 19.7
#> [31] 15.0 21.4
rlang::eval_tidy(form_b[[2]], mtcars)
#> Error: object '.' not found

# but:
rlang::f_lhs(form_a)
#> mpg
rlang::f_lhs(form_b)
#> NULL

# gives:
rlang::eval_tidy(rlang::f_lhs(form_a), mtcars)
#>  [1] 21.0 21.0 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 17.8 16.4 17.3 15.2 10.4
#> [16] 10.4 14.7 32.4 30.4 33.9 21.5 15.5 15.2 13.3 19.2 27.3 26.0 30.4 15.8 19.7
#> [31] 15.0 21.4
rlang::eval_tidy(rlang::f_lhs(form_b), mtcars)
#> NULL

Created on 2023-11-02 with reprex v2.0.2

This will give us some better information to work with in check_outcome().

Copy link
Member

@EmilHvitfeldt EmilHvitfeldt left a comment

Choose a reason for hiding this comment

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

Very nice!

@simonpcouch simonpcouch merged commit 1afcd2f into main Nov 3, 2023
@simonpcouch simonpcouch deleted the f-lhs branch November 3, 2023 13:55
@github-actions
Copy link
Contributor

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants