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

Allow use of select helpers in col_exists() #221

Closed
rich-iannone opened this issue Oct 30, 2020 · 1 comment
Closed

Allow use of select helpers in col_exists() #221

rich-iannone opened this issue Oct 30, 2020 · 1 comment

Comments

@rich-iannone
Copy link
Member

Allowing col_exists() to use select helpers would be useful for checking the presence of columns that match a pattern or begin with a known prefix.

@yjunechoe
Copy link
Collaborator

Now possible!

get_info <- function(x) {
  suppressMessages(interrogate(x)) %>% 
    el("validation_set") %>% 
    dplyr::select(5:7, 15) %>% 
    dplyr::mutate(column = unlist(column))
}

create_agent(small_table) %>% 
  col_exists(
    columns = starts_with("date"),
    label = "The time column {.col} exists"
  ) %>% 
  get_info()
#> # A tibble: 2 × 4
#>   assertion_type columns_expr            column    label                           
#>   <chr>          <chr>                   <chr>     <chr>                           
#> 1 col_exists     "starts_with(\"date\")" date_time The time column date_time exists
#> 2 col_exists     "starts_with(\"date\")" date      The time column date exists

create_agent(small_table) %>% 
  col_exists(
    columns = where(lubridate::is.timepoint),
    label = "The time column {.col} exists"
  ) %>% 
  get_info()
#> # A tibble: 2 × 4
#>   assertion_type columns_expr                   column    label                           
#>   <chr>          <chr>                          <chr>     <chr>                           
#> 1 col_exists     where(lubridate::is.timepoint) date_time The time column date_time exists
#> 2 col_exists     where(lubridate::is.timepoint) date      The time column date exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants