Skip to content

Commit

Permalink
fix bug causing error when validate_cond had more than 1 conditional col
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbarks committed Mar 21, 2024
1 parent 8680b3f commit 3791270
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
^qxl\.Rproj$
^\.Rproj\.user$
^archive$
^data-raw$
^README\.Rmd$
^LICENSE\.md$
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Imports:
readxl,
dplyr,
rlang,
tidyr,
lubridate
Suggests:
testthat (>= 3.0.0),
tibble,
tidyr,
covr
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ importFrom(rlang,eval_tidy)
importFrom(rlang,is_quosure)
importFrom(rlang,quo_get_expr)
importFrom(stats,setNames)
importFrom(tidyr,unnest)
11 changes: 5 additions & 6 deletions R/qxl.R
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ qxl <- function(x,
#' @noRd
#' @import openxlsx
#' @importFrom stats setNames
#' @importFrom tidyr unnest
#' @importFrom dplyr everything select mutate arrange relocate `%>%` all_of
#' bind_rows across cur_group_id group_by ungroup n summarize left_join
#' distinct
Expand Down Expand Up @@ -614,14 +615,12 @@ qxl_ <- function(x,

if (!is.null(validate_cond_all)) {

validate_cond_all_df <- expand.grid(
x = sort(unique(x[[cols_cond]])),
y = validate_cond_all
) %>%
validate_cond_all_df <- unique(x[,cols_cond, drop = FALSE]) %>%
mutate(replacement = list(validate_cond_all)) %>%
tidyr::unnest("replacement") %>%
stats::setNames(c(cols_cond, col_validation))

validate_cond_df <- validate_cond_df %>%
bind_rows(validate_cond_all_df) %>%
validate_cond_df <- bind_rows(validate_cond_df, validate_cond_all_df) %>%
arrange(across(all_of(cols_cond)))
}

Expand Down

0 comments on commit 3791270

Please sign in to comment.