Skip to content

Commit

Permalink
Remove ordered, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rsh52 committed Nov 12, 2024
1 parent f335bf4 commit 573caff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions R/read_redcap.R
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,7 @@ add_event_mapping <- function(supertbl, linked_arms, repeat_event_types) {
if (!is.null(repeat_event_types)) {
# Preserve factor levels post-join by referencing level order from linked_arms
repeat_event_types$redcap_event_name <- factor(repeat_event_types$redcap_event_name,
levels = levels(event_info$unique_event_name),
ordered = TRUE
levels = levels(event_info$unique_event_name)
)

event_info <- event_info %>%
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ link_arms <- function(redcap_uri,
left_join(db_event_instruments, arms, by = "arm_num") %>%
left_join(db_event_labels, by = c("arm_num", "unique_event_name")) %>%
mutate(
across(any_of("unique_event_name"), ~ fct_inorder(.x, ordered = TRUE)),
across(any_of("event_name"), ~ fct_inorder(.x, ordered = TRUE))
across(any_of("unique_event_name"), ~ fct_inorder(.x)),
across(any_of("event_name"), ~ fct_inorder(.x))
)
}

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ test_that("link_arms works", {
# all arms are represented in output (test redcap has 2 arms)
n_unique_arms <- length(unique(out$arm_num))
expect_equal(n_unique_arms, 2)
expect_s3_class(out$unique_event_name, "ordered")
expect_s3_class(out$event_name, "ordered")
expect_s3_class(out$unique_event_name, "factor")
expect_s3_class(out$event_name, "factor")
expect_equal(
levels(out$unique_event_name),
c("event_1_arm_1", "event_2_arm_1", "event_1_arm_2", "event_3_arm_2")
Expand Down

0 comments on commit 573caff

Please sign in to comment.