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

Ensure column string is symbol before constructing expression for col_vals_*() functions #531

Merged
merged 2 commits into from
Mar 16, 2024

Conversation

yjunechoe
Copy link
Collaborator

Resolves #530

This PR preserves columns as symbols in the internal tbl_val_comparison() function.

Instead of creating an expression out of this string:

"column name < 1000"

We now immediately evaluate to the correct expression, using call():

`column name` < 1000

Reprex:

agent <- mtcars |> 
  dplyr::rename(`disp units` = disp) |>
  create_agent() |> 
  col_vals_lt(`disp units`, 1000) |>
  interrogate()
#> 
#> ── Interrogation Started - there is a single validation step ──────────────────
#> ✔ Step 1: OK.
#> 
#> ── Interrogation Completed ────────────────────────────────────────────────────
get_agent_report(agent, display_table = FALSE)
#> # A tibble: 1 × 14
#>       i type       columns values precon active eval  units n_pass f_pass W    
#>   <int> <chr>      <chr>   <chr>  <chr>  <lgl>  <chr> <dbl>  <dbl>  <dbl> <lgl>
#> 1     1 col_vals_… disp u… 1000   <NA>   TRUE   OK       32     32      1 NA   
#> # ℹ 3 more variables: S <lgl>, N <lgl>, extract <int>

Copy link
Member

@rich-iannone rich-iannone left a comment

Choose a reason for hiding this comment

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

LGTM!

@rich-iannone rich-iannone merged commit 1cf7733 into rstudio:main Mar 16, 2024
12 of 13 checks passed
@yjunechoe yjunechoe deleted the tbl_val_comparison-column-symbol branch March 18, 2024 11:10
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.

Column names with spaces causes incorrect validation error
2 participants