From 573cafff7b56bee0963448ed6bba47707adb63d4 Mon Sep 17 00:00:00 2001 From: Richard Hanna Date: Tue, 12 Nov 2024 09:38:45 -0500 Subject: [PATCH] Remove ordered, fix tests --- R/read_redcap.R | 3 +-- R/utils.R | 4 ++-- tests/testthat/test-utils.R | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/R/read_redcap.R b/R/read_redcap.R index acec2234..db560149 100644 --- a/R/read_redcap.R +++ b/R/read_redcap.R @@ -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 %>% diff --git a/R/utils.R b/R/utils.R index b2edfe22..5d5555a2 100644 --- a/R/utils.R +++ b/R/utils.R @@ -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)) ) } diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 0d7550c4..df577ec9 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -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")