Skip to content

Commit

Permalink
Merge branch 'main' into issue_222
Browse files Browse the repository at this point in the history
  • Loading branch information
ddsjoberg authored Jan 23, 2025
2 parents 6a1fcd2 + 7d2ef50 commit 50546f0
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'oldrel-4'}
# - {os: ubuntu-latest, r: 'oldrel-3'}
# - {os: ubuntu-latest, r: 'oldrel-4'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
2 changes: 2 additions & 0 deletions R/scale_ggsurvfit.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#' - `scale_y_continuous(expand = c(0.025, 0), limits = c(0, 1), label = scales::label_percent())`.
#' - `scale_x_continuous(expand = c(0.015, 0), n.breaks = 8)`
#'
#' *NOTE*: The y-axis limits are only set for survival curves.
#'
#' If you use this function, you **must** include **all** scale specifications
#' that would appear in `scale_x_continuous()` or `scale_y_continuous()`.
#' For example, it's common you'll need to specify the x-axis break points.
Expand Down
1 change: 1 addition & 0 deletions ggsurvfit.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: bc923b98-5bad-45ab-b348-e227eecb86bc

RestoreWorkspace: No
SaveWorkspace: No
Expand Down
2 changes: 2 additions & 0 deletions man/scale_ggsurvfit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 27 additions & 9 deletions tests/testthat/test-ggsurvfit.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ test_that("ggsurvfit() works", {
vdiffr::expect_doppelganger("sf2-ggsurvfit_linetype", lst_survfit2_linetype[[1]])
vdiffr::expect_doppelganger("sf3-ggsurvfit_linetype", lst_survfit2_linetype[[2]])

expect_error(
lst_survfit_KMunicate <-
list(sf1, sf2, sf3) %>%
lapply(function(x) ggsurvfit(x, theme = theme_ggsurvfit_KMunicate())),
NA
)
vdiffr::expect_doppelganger("sf1-ggsurvfit-KMunicate", lst_survfit_KMunicate[[1]])
vdiffr::expect_doppelganger("sf2-ggsurvfit-KMunicate", lst_survfit_KMunicate[[2]])
vdiffr::expect_doppelganger("sf3-ggsurvfit-KMunicate", lst_survfit_KMunicate[[3]])

# test that the variable names are stripped when using transformations
vdiffr::expect_doppelganger(
Expand Down Expand Up @@ -193,3 +184,30 @@ test_that("ggsurvfit() works with geoms with new data", {
vdiffr::expect_doppelganger("sf2-ggsurvfit_new_data_geom1", p1)
vdiffr::expect_doppelganger("sf2-ggsurvfit_new_data_geom2", p2)
})

test_that("KMunicate theme is working and reproducible", {

expect_no_error(
lst_survfit_KMunicate <-
list(sf1, sf2, sf3) %>%
lapply(function(x) ggsurvfit(x, theme = theme_ggsurvfit_KMunicate()))
)

vdiffr::expect_doppelganger("sf1-ggsurvfit-KMunicate", lst_survfit_KMunicate[[1]])
vdiffr::expect_doppelganger("sf2-ggsurvfit-KMunicate", lst_survfit_KMunicate[[2]])
vdiffr::expect_doppelganger("sf3-ggsurvfit-KMunicate", lst_survfit_KMunicate[[3]])

#plot from the documentation
p <- survfit2(Surv(time, status) ~ surg, data = df_colon) %>%
ggsurvfit(linetype_aes = TRUE) +
add_confidence_interval() +
add_risktable(
risktable_stats = c("n.risk", "cum.censor", "cum.event")
) +
theme_ggsurvfit_KMunicate() +
scale_y_continuous(limits = c(0, 1)) +
scale_x_continuous(expand = c(0.02, 0)) +
theme(legend.position="inside", legend.position.inside = c(0.85, 0.85))
vdiffr::expect_doppelganger("vignette-ggsurvfit-KMunicate", p)
})

2 changes: 1 addition & 1 deletion vignettes/articles/gallery.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ survfit2(Surv(time, status) ~ surg, data = df_colon) %>%
theme_ggsurvfit_KMunicate() +
scale_y_continuous(limits = c(0, 1)) +
scale_x_continuous(expand = c(0.02, 0)) +
theme(legend.position.inside = c(0.85, 0.85))
theme(legend.position="inside", legend.position.inside = c(0.85, 0.85))
```

## Swap Line Type & Color Aesthetics
Expand Down

0 comments on commit 50546f0

Please # to comment.