From e47693688906443d9bd6c924fdec5631bb31ab86 Mon Sep 17 00:00:00 2001 From: Richard Hanna Date: Wed, 6 Mar 2024 10:30:00 -0500 Subject: [PATCH] Styler and lintr --- R/clean_redcap_long.R | 11 +++++------ tests/testthat/test-clean_redcap_long.R | 12 ++++++++---- vignettes/articles/diving_deeper.Rmd | 5 +++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/R/clean_redcap_long.R b/R/clean_redcap_long.R index c4858761..a2b55f7f 100644 --- a/R/clean_redcap_long.R +++ b/R/clean_redcap_long.R @@ -86,7 +86,7 @@ clean_redcap_long <- function(db_data_long, mixed_structure_ref <- get_mixed_structure_fields(db_data_long) %>% filter(.data$rep_and_nonrep & !str_ends(.data$field_name, "_form_complete")) %>% left_join(db_metadata_long %>% select(.data$field_name, .data$form_name), - by = "field_name" + by = "field_name" ) # Update if project actually has mixed structure @@ -96,7 +96,6 @@ clean_redcap_long <- function(db_data_long, if (has_mixed_structure_forms) { db_data_long <- convert_mixed_instrument(db_data_long, mixed_structure_ref) } - } else { # Throw error if mixed structure detected and not allowed check_repeat_and_nonrepeat(db_data_long) @@ -113,8 +112,10 @@ clean_redcap_long <- function(db_data_long, linked_arms ) ), - structure = case_when(has_mixed_structure_forms & redcap_form_name %in% mixed_structure_ref$form_name ~ "mixed", - TRUE ~ "repeating") + structure = case_when( + has_mixed_structure_forms & redcap_form_name %in% mixed_structure_ref$form_name ~ "mixed", + TRUE ~ "repeating" + ) ) } @@ -274,7 +275,6 @@ distill_repeat_table_long <- function(form_name, db_data_long, db_metadata_long, linked_arms) { - has_repeat_forms <- "redcap_repeat_instance" %in% names(db_data_long) my_record_id <- names(db_data_long)[1] @@ -391,7 +391,6 @@ distill_repeat_table_long <- function(form_name, #' @keywords internal convert_mixed_instrument <- function(db_data_long, mixed_structure_ref) { - for (i in seq_len(nrow(mixed_structure_ref))) { field <- mixed_structure_ref$field_name[i] form <- mixed_structure_ref$form_name[i] diff --git a/tests/testthat/test-clean_redcap_long.R b/tests/testthat/test-clean_redcap_long.R index 93de218f..04f479f0 100644 --- a/tests/testthat/test-clean_redcap_long.R +++ b/tests/testthat/test-clean_redcap_long.R @@ -123,11 +123,15 @@ test_that("clean_redcap_long with mixed structure works", { 1, "event_2", "Nonrepeat 2", 0 ) - expect_equal(out$redcap_data[out$redcap_form_name == "mixed_structure_form"][[1]], - expected_mixed_data) + expect_equal( + out$redcap_data[out$redcap_form_name == "mixed_structure_form"][[1]], + expected_mixed_data + ) - expect_equal(out$redcap_data[out$redcap_form_name == "nonrepeat_form"][[1]], - expected_nonrepeat_data) + expect_equal( + out$redcap_data[out$redcap_form_name == "nonrepeat_form"][[1]], + expected_nonrepeat_data + ) }) test_that("distill_nonrepeat_table_long tibble contains expected columns for longitudinal REDCap databases with arms", { diff --git a/vignettes/articles/diving_deeper.Rmd b/vignettes/articles/diving_deeper.Rmd index 70812382..8d4d5e48 100644 --- a/vignettes/articles/diving_deeper.Rmd +++ b/vignettes/articles/diving_deeper.Rmd @@ -191,8 +191,9 @@ Users are cautioned when enabling this feature, since it changes definitions in ```{r} read_redcap(redcap_uri, - mixed_token, - allow_mixed_structure = TRUE) |> + mixed_token, + allow_mixed_structure = TRUE +) |> rmarkdown::paged_table() ```