Skip to content

Commit 83f6e41

Browse files
authored
Even more nonsense (pharmaverse#183)
* progress * Update test-coverage.yaml * Update test-coverage.yaml
1 parent 968b121 commit 83f6e41

File tree

6 files changed

+23
-18
lines changed

6 files changed

+23
-18
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: ggsurvfit
22
Title: Flexible Time-to-Event Figures
3-
Version: 0.3.1.9003
3+
Version: 0.3.1.9004
44
Authors@R: c(
55
person("Daniel D.", "Sjoberg", , "[email protected]", role = c("aut", "cre", "cph"),
66
comment = c(ORCID = "0000-0003-0862-2018")),

NEWS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ggsurvfit (development version)
22

3-
* By default, a model plot created with `ggsurvfit()` or `ggcuminc()` uses the color aesthetic to plot curves by the stratifying variable(s), and further, `ggcuminc()` uses the linetype aesthetic for plots that contain multiple outcomes (i.e. competing events). We now introduce the global option `"ggsurvfit.switch-color-linetype"` to switch these defaults, giving users more flexibility over the output figures. (#166)
3+
* By default, a model plot created with `ggsurvfit()` or `ggcuminc()` uses the color aesthetic to plot curves by the stratifying variable(s), and further, `ggcuminc()` uses the linetype aesthetic for plots that contain multiple outcomes (i.e. competing events). We now introduce the global option `"ggsurvfit.switch-color-linetype"` to switch these defaults, giving users more flexibility over the output figures. Furthermore, when the `linetype_aes=` argument is called in a situation when it does not apply, it will be silently ignored (previsouly, an error message _may_ have been thrown). (#166)
44

55
* Slightly increased the padding to the right of the plot when `scale_ggsurvfit()` is called. (#165)
66

R/ggsurvfit.R

+13-11
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,19 @@ ggsurvfit <- function(x, type = "survival",
107107

108108
# prepare `aes()` call
109109
.construct_aes <- function(df, linetype_aes, outcome = NULL) {
110-
if (!is.null(outcome) &&
111-
length(outcome) > 1 &&
112-
isTRUE(linetype_aes) &&
113-
!isTRUE(getOption("ggsurvfit.switch-color-linetype"))) {
114-
cli_abort("Cannot specify multiple outcomes with {.code linetype_aes=TRUE}.")
115-
}
116-
if ("strata" %in% names(df) &&
117-
length(unique(df$strata)) > 1 &&
118-
isTRUE(linetype_aes) &&
119-
isTRUE(getOption("ggsurvfit.switch-color-linetype"))) {
120-
cli_abort("Cannot specify stratum with {.code linetype_aes=TRUE}.")
110+
# if `linetype_aes` specified in an inappropriate situation, it is silently ignored
111+
if (
112+
isTRUE(linetype_aes) &&
113+
!(
114+
(is.null(outcome) && "strata" %in% names(df) && !isTRUE(getOption("ggsurvfit.switch-color-linetype"))) || # ggsurvfit with strata
115+
(!is.null(outcome) && length(outcome) == 1L && "strata" %in% names(df) && !isTRUE(getOption("ggsurvfit.switch-color-linetype"))) || # ggcuminc with 1 outcome and strata
116+
(!is.null(outcome) && length(outcome) > 1L && !"strata" %in% names(df) && isTRUE(getOption("ggsurvfit.switch-color-linetype"))) # ggcuminc with 2+ outcomes and no strata
117+
)
118+
) {
119+
linetype_aes <- FALSE
121120
}
122121

122+
123123
# setting aes() --------------------------------------------------------------
124124
aes_args <-
125125
list(
@@ -154,6 +154,8 @@ ggsurvfit <- function(x, type = "survival",
154154
)
155155
)
156156
}
157+
158+
# adding linetype_aes argument -----------------------------------------------
157159
if (isTRUE(linetype_aes) &&
158160
"strata" %in% names(df) &&
159161
!isTRUE(getOption("ggsurvfit.switch-color-linetype"))) {

README.Rmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ knitr::opts_chunk$set(
1717
# ggsurvfit <a href="https://www.danieldsjoberg.com/ggsurvfit/"><img src="man/figures/logo.png" align="right" height="138" /></a>
1818

1919
<!-- badges: start -->
20-
[![R-CMD-check](https://github.com/pharmaverse/ggsurvfit/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ddsjoberg/ggsurvfit/actions/workflows/R-CMD-check.yaml)
21-
[![Codecov test coverage](https://codecov.io/gh/pharmaverse/ggsurvfit/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ddsjoberg/ggsurvfit?branch=main)
20+
[![R-CMD-check](https://github.com/pharmaverse/ggsurvfit/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/pharmaverse/ggsurvfit/actions/workflows/R-CMD-check.yaml)
21+
[![Codecov test coverage](https://codecov.io/gh/pharmaverse/ggsurvfit/branch/main/graph/badge.svg)](https://app.codecov.io/gh/pharmaverse/ggsurvfit?branch=main)
2222
[![CRAN status](https://www.r-pkg.org/badges/version/ggsurvfit)](https://CRAN.R-project.org/package=ggsurvfit)
2323
[![](https://cranlogs.r-pkg.org/badges/ggsurvfit)](https://cran.r-project.org/package=ggsurvfit)
2424
[<img src="http://pharmaverse.org/shields/ggsurvfit.svg">](https://pharmaverse.org)

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
<!-- badges: start -->
77

8-
[![R-CMD-check](https://github.com/pharmaverse/ggsurvfit/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ddsjoberg/ggsurvfit/actions/workflows/R-CMD-check.yaml)
8+
[![R-CMD-check](https://github.com/pharmaverse/ggsurvfit/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/pharmaverse/ggsurvfit/actions/workflows/R-CMD-check.yaml)
99
[![Codecov test
10-
coverage](https://codecov.io/gh/pharmaverse/ggsurvfit/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ddsjoberg/ggsurvfit?branch=main)
10+
coverage](https://codecov.io/gh/pharmaverse/ggsurvfit/branch/main/graph/badge.svg)](https://app.codecov.io/gh/pharmaverse/ggsurvfit?branch=main)
1111
[![CRAN
1212
status](https://www.r-pkg.org/badges/version/ggsurvfit)](https://CRAN.R-project.org/package=ggsurvfit)
1313
[![](https://cranlogs.r-pkg.org/badges/ggsurvfit)](https://cran.r-project.org/package=ggsurvfit)

tests/testthat/test-ggcuminc.R

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ test_that("ggcuminc() works", {
1919

2020
expect_error(ggcuminc(mtcars))
2121
expect_error(ggcuminc(cuminc1, outcome = "not an outcome"))
22+
23+
# the linetype_aes argument is silently ignored here
2224
expect_error(
2325
ggcuminc(cuminc1,
2426
outcome = c("death from cancer", "death other causes"),
25-
linetype_aes = TRUE)
27+
linetype_aes = TRUE),
28+
NA
2629
)
2730
expect_error(
2831
ggcuminc(cuminc1, outcome = c("death from cancer", "death other causes")),

0 commit comments

Comments
 (0)