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

Show used columns in col_vals_expr() #505

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

yjunechoe
Copy link
Collaborator

@yjunechoe yjunechoe commented Nov 5, 2023

Summary

This PR aims to have col_vals_expr() show columns used in expr in the agent report. Example inspired by fn docs:

tbl <-
  dplyr::tibble(
    a = c(1, 2, 1, 7, 8, 6),
    b = c(0, 0, 0, 1, 1, 1),
    c = c(0.5, 0.3, 0.8, 1.4, 1.9, 1.2),
  )
c <- 1

tbl %>%
  create_agent() %>% 
  col_vals_expr(expr = ~ a %% 1 == 0) %>% 
  col_vals_expr(expr = ~ case_when(
    b == 0 ~ a %>% between(0, 5) & c < 1,
    b == 1 ~ a > 5 & c >= 1
  )) %>% 
  col_vals_expr(expr(.data$a + b == !!c)) %>% 
  col_vals_expr(expr = ~ a + d > 0) %>% 
  interrogate()

image

This is a draft because it needs more tests.

Related GitHub Issues and PRs

Checklist

@yjunechoe
Copy link
Collaborator Author

Apparently {covr} injects its own expressions into even quote()/expr()-ed code - r-lib/covr#381. This unfortunately interferes with the expr parsing process and makes the new feature impossible to test on the test-coverage/codecov GHA.

I'm trying to find a good way around this but the good thing is that this feature is purely a convenience of display in the agent report, so currently I have it failing gracefully in case of parsing errors (falls back to showing nothing for columns) and I'll think more about what I can do w.r.t. including it in (automated) tests.

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

1 participant