From ff1a3772ccb2de65e7ef0c3a54460abc081709f6 Mon Sep 17 00:00:00 2001
From: John Kirkpatrick <133956382+Puzzled-Face@users.noreply.github.com>
Date: Mon, 14 Oct 2024 11:48:38 +0100
Subject: [PATCH] Fix #866 (#867)
* Fix #866
* [skip style] [skip vbump] Restyle files
---------
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
---
R/Data-methods.R | 22 +-
...ot-of-datada-with-placebo-and-blinding.svg | 355 ++++++++-------
.../plot-of-datada-with-placebo.svg | 403 +++++++++---------
...-of-datadual-with-placebo-and-blinding.svg | 252 +++++------
.../plot-of-datadual-with-placebo.svg | 306 ++++++-------
tests/testthat/test-Data-methods.R | 13 +
6 files changed, 686 insertions(+), 665 deletions(-)
diff --git a/R/Data-methods.R b/R/Data-methods.R
index 3d0baf7a1..81900ca7b 100644
--- a/R/Data-methods.R
+++ b/R/Data-methods.R
@@ -984,7 +984,7 @@ setMethod(
f = "tidy",
signature = signature(x = "DataOrdinal"),
definition = function(x, ...) {
- tibble::tibble(
+ y <- tibble::tibble(
ID = x@ID,
Cohort = x@cohort,
Dose = x@x,
@@ -1000,8 +1000,22 @@ setMethod(
values_from = "Tox",
names_prefix = "Cat",
values_fill = 0
- ) %>%
- dplyr::mutate(dplyr::across(tidyselect::matches("Cat\\d+"), \(x) x > 0)) %>%
- h_tidy_class(x)
+ )
+ if (nrow(y) > 0) {
+ y <- y %>%
+ dplyr::mutate(
+ dplyr::across(tidyselect::matches("Cat\\d+"), \(x) x > 0)
+ ) %>%
+ dplyr::rowwise() %>%
+ dplyr::mutate(
+ AnyTox = any(dplyr::across(c(tidyselect::starts_with("Cat"), -Cat0), any)),
+ # Direct assignment fails on GitHub
+ Cat0 = !AnyTox
+ ) %>%
+ dplyr::select(-AnyTox) %>%
+ dplyr::ungroup()
+ }
+ y <- y %>% h_tidy_class(x)
+ y
}
)
diff --git a/tests/testthat/_snaps/Data-methods/plot-of-datada-with-placebo-and-blinding.svg b/tests/testthat/_snaps/Data-methods/plot-of-datada-with-placebo-and-blinding.svg
index fd95cb55f..8d015a8da 100644
--- a/tests/testthat/_snaps/Data-methods/plot-of-datada-with-placebo-and-blinding.svg
+++ b/tests/testthat/_snaps/Data-methods/plot-of-datada-with-placebo-and-blinding.svg
@@ -21,87 +21,87 @@
-
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-0
-25
-50
-100
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-Patient
-Dose Level
+0
+25
+50
+100
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+Patient
+Dose Level
@@ -114,118 +114,115 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0
-50
-100
-150
-Time
-Patient
-
-Toxicity
-
-
-
-
-
-
-
-
-
-No
-Start
-Yes
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+0
+50
+100
+150
+Time
+Patient
+
+Toxicity
+
+
+
+
+
+
+No
+Start
+Yes
diff --git a/tests/testthat/_snaps/Data-methods/plot-of-datada-with-placebo.svg b/tests/testthat/_snaps/Data-methods/plot-of-datada-with-placebo.svg
index 42945b844..0f510a787 100644
--- a/tests/testthat/_snaps/Data-methods/plot-of-datada-with-placebo.svg
+++ b/tests/testthat/_snaps/Data-methods/plot-of-datada-with-placebo.svg
@@ -21,99 +21,99 @@
-
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
-0
-25
-50
-100
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-Patient
-Dose Level
+0
+25
+50
+100
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+Patient
+Dose Level
@@ -126,130 +126,127 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0
-50
-100
-150
-Time
-Patient
-
-Toxicity
-
-
-
-
-
-
-
-
-
-No
-Start
-Yes
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+0
+50
+100
+150
+Time
+Patient
+
+Toxicity
+
+
+
+
+
+
+No
+Start
+Yes
diff --git a/tests/testthat/_snaps/Data-methods/plot-of-datadual-with-placebo-and-blinding.svg b/tests/testthat/_snaps/Data-methods/plot-of-datadual-with-placebo-and-blinding.svg
index 485c4b78f..4071d4a43 100644
--- a/tests/testthat/_snaps/Data-methods/plot-of-datadual-with-placebo-and-blinding.svg
+++ b/tests/testthat/_snaps/Data-methods/plot-of-datadual-with-placebo-and-blinding.svg
@@ -30,78 +30,78 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-0
-25
-50
-100
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-Patient
-Dose Level
+0
+25
+50
+100
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+Patient
+Dose Level
@@ -114,67 +114,67 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-25
-50
-75
-100
-
-
-
-
-
-
-
-
-40
-60
-80
-100
-Dose Level
-Biomarker
-
-Toxicity
-
-
-
-
-No
-Yes
+25
+50
+75
+100
+
+
+
+
+
+
+
+
+40
+60
+80
+100
+Dose Level
+Biomarker
+
+Toxicity
+
+
+
+
+No
+Yes
diff --git a/tests/testthat/_snaps/Data-methods/plot-of-datadual-with-placebo.svg b/tests/testthat/_snaps/Data-methods/plot-of-datadual-with-placebo.svg
index 1131cd122..db6afc7db 100644
--- a/tests/testthat/_snaps/Data-methods/plot-of-datadual-with-placebo.svg
+++ b/tests/testthat/_snaps/Data-methods/plot-of-datadual-with-placebo.svg
@@ -30,90 +30,90 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
-0
-25
-50
-100
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-Patient
-Dose Level
+0
+25
+50
+100
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+Patient
+Dose Level
@@ -126,82 +126,82 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
-25
-50
-75
-100
-
-
-
-
-
-
-
-
-
-0
-25
-50
-75
-100
-Dose Level
-Biomarker
-
-Toxicity
-
-
-
-
-No
-Yes
+25
+50
+75
+100
+
+
+
+
+
+
+
+
+
+0
+25
+50
+75
+100
+Dose Level
+Biomarker
+
+Toxicity
+
+
+
+
+No
+Yes
diff --git a/tests/testthat/test-Data-methods.R b/tests/testthat/test-Data-methods.R
index 7b0a76a51..7a501905a 100644
--- a/tests/testthat/test-Data-methods.R
+++ b/tests/testthat/test-Data-methods.R
@@ -656,3 +656,16 @@ test_that("tidy-DataGeneral creates the correct tibble", {
expected$Tox <- c(FALSE, TRUE, FALSE)
expect_equal(tidy(d), expected)
})
+
+test_that("tidy-Dataordinal creates the correct tibble", {
+ tidyData <- .DefaultDataOrdinal() %>% tidy()
+ x <- .DefaultDataOrdinal() %>% tidy()
+ actual <- x %>%
+ dplyr::rowwise() %>%
+ dplyr::mutate(
+ AnyTox = any(dplyr::across(c(starts_with("Cat"), -Cat0), any)),
+ ExpectedCat0 = !AnyTox
+ )
+
+ expect_equal(actual$Cat0, actual$ExpectedCat0)
+})