Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions R/yaml_read_agent.R
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,12 @@ make_validation_steps <- function(steps) {
FUN = function(x) {

step_i <- steps[[x]]

# Handle scalar steps (no arguments): `- rows_distinct` in YAML
if (is.character(step_i)) {
return(paste0("%>%\n", step_i, "()"))
}

step_fn <- names(step_i)

args <-
Expand Down
10 changes: 4 additions & 6 deletions R/yaml_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,8 @@
#' columns: c(date, date_time)
#' - col_vals_regex:
#' columns: c(b)
#' regex: '[0-9]-[a-z]{3}-[0-9]{3}'
#' - rows_distinct:
#' columns: ~
#' pattern: '[0-9]-[a-z]{3}-[0-9]{3}'
#' - rows_distinct
#' - col_vals_gt:
#' columns: c(d)
#' value: 100.0
Expand Down Expand Up @@ -621,9 +620,8 @@ yaml_write <- function(
#' columns: vars(date_time)
#' - col_vals_regex:
#' columns: vars(b)
#' regex: '[0-9]-[a-z]{3}-[0-9]{3}'
#' - rows_distinct:
#' columns: ~
#' pattern: '[0-9]-[a-z]{3}-[0-9]{3}'
#' - rows_distinct
#' - col_vals_gt:
#' columns: vars(d)
#' value: 100.0
Expand Down
3 changes: 1 addition & 2 deletions inst/yaml/agent-small_table.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ steps:
- col_vals_regex:
columns: vars(b)
pattern: '[0-9]-[a-z]{3}-[0-9]{3}'
- rows_distinct:
columns: ~
- rows_distinct
- col_vals_gt:
columns: vars(d)
value: 100.0
Expand Down
3 changes: 1 addition & 2 deletions vignettes/YAML.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ steps:
pattern: '^[0-9]-[a-z]{3}-[0-9]{3}$'

# rows_distinct()
- rows_distinct:
columns: ~
- rows_distinct
```

Arguments that use R expressions (like column selections via `vars()`) are stored as strings and evaluated when the YAML is read back.
Expand Down
Loading