Skip to content

Commit ad70e68

Browse files
authored
Merge pull request #43 from scacola/master
nejm.surv.by
2 parents 319826c + c2e794f commit ad70e68

File tree

6 files changed

+43
-10
lines changed

6 files changed

+43
-10
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: jskm
22
Title: Kaplan-Meier Plot with 'ggplot2'
3-
Version: 0.5.12
4-
Date: 2025-03-18
3+
Version: 0.5.13
4+
Date: 2025-06-11
55
Authors@R: c(person("Jinseob", "Kim", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9403-605X")),
66
person("yoonkyoung", "Chun", email = "[email protected]", role = "aut"),
77
person("Zarathu", role = c("cph", "fnd")),

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# jskm 0.5.13
2+
3+
* Update: Add `nejm.surv.by` option to y-axis breaks in `jskm` and `svyjskm`.
4+
15
# jskm 0.5.12
26

37
* Update: Add censoring marks

R/jskm.R

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#' @param nejm.infigure.ratioh Ratio of infigure height to total height, Default = 0.5
4141
#' @param nejm.infigure.ylim y-axis limit of infigure, Default = c(0,1)
4242
#' @param surv.by breaks unit in y-axis, default = NULL(ggplot default)
43+
#' @param nejm.surv.by breaks unit in y-axis in nejm figure, default = NULL(ggplot default)
4344
#' @param hr logical: add the hazard ratio to the plot?
4445
#' @param hr.size numeric value specifying the HR text size. Default is 5.
4546
#' @param hr.coord numeric vector, of length 2, specifying the x and y coordinates of the p-value. Default values are NULL
@@ -130,6 +131,7 @@ jskm <- function(sfit,
130131
nejm.infigure.ratioh = 0.5,
131132
nejm.infigure.ylim = c(0, 1),
132133
surv.by = NULL,
134+
nejm.surv.by = NULL,
133135
hr = FALSE,
134136
hr.size = 5,
135137
hr.coord = c(NULL, NULL),
@@ -984,10 +986,20 @@ jskm <- function(sfit,
984986
#######################
985987

986988
if (!is.null(theme) && theme == "nejm") {
987-
p2 <- p1 + coord_cartesian(ylim = nejm.infigure.ylim) + theme(
988-
axis.title.x = element_blank(), axis.title.y = element_blank(),
989-
axis.text = element_text(size = 10 * nejm.infigure.ratiow),
990-
) + guides(colour = "none", linetype = "none") + scale_y_continuous(limits = nejm.infigure.ylim, breaks = waiver(), labels = scale_labels)
989+
990+
if(!is.null(nejm.surv.by)){
991+
p2 <- p1 + coord_cartesian(ylim = nejm.infigure.ylim) + theme(
992+
axis.title.x = element_blank(), axis.title.y = element_blank(),
993+
axis.text = element_text(size = 10 * nejm.infigure.ratiow),
994+
) + guides(colour = "none", linetype = "none") + scale_y_continuous(limits = nejm.infigure.ylim, breaks = seq(nejm.infigure.ylim[1], nejm.infigure.ylim[2], by = nejm.surv.by), labels = scale_labels)
995+
}else{
996+
p2 <- p1 + coord_cartesian(ylim = nejm.infigure.ylim) + theme(
997+
axis.title.x = element_blank(), axis.title.y = element_blank(),
998+
axis.text = element_text(size = 10 * nejm.infigure.ratiow),
999+
) + guides(colour = "none", linetype = "none") + scale_y_continuous(limits = nejm.infigure.ylim, breaks = waiver(), labels = scale_labels)
1000+
}
1001+
1002+
9911003
p <- p + patchwork::inset_element(p2, 1 - nejm.infigure.ratiow, 1 - nejm.infigure.ratioh, 1, 1, align_to = "panel")
9921004
}
9931005

R/svyjskm.R

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#' @param nejm.infigure.ratioh Ratio of infigure height to total height, Default = 0.5
4040
#' @param nejm.infigure.ylim y-axis limit of infigure, Default = c(0,1)
4141
#' @param surv.by breaks unit in y-axis, default = NULL(ggplot default)
42+
#' @param nejm.surv.by breaks unit in y-axis in nejm figure, default = NULL(ggplot default)
4243
#' @param ... PARAM_DESCRIPTION
4344
#' @return plot
4445
#' @details DETAILS
@@ -99,6 +100,7 @@ svyjskm <- function(sfit,
99100
nejm.infigure.ratioh = 0.5,
100101
nejm.infigure.ylim = c(0, 1),
101102
surv.by = NULL,
103+
nejm.surv.by = NULL,
102104
...) {
103105
n.censor <- surv <- strata <- lower <- upper <- NULL
104106

@@ -914,10 +916,19 @@ svyjskm <- function(sfit,
914916
# Plotting the graphs #
915917
#######################
916918
if (!is.null(theme) && theme == "nejm") {
917-
p2 <- p1 + coord_cartesian(ylim = nejm.infigure.ylim) + theme(
918-
axis.title.x = element_blank(), axis.title.y = element_blank(),
919-
axis.text = element_text(size = 10 * nejm.infigure.ratiow) + scale_y_continuous(limits = nejm.infigure.ylim, breaks = waiver(), labels = scale_labels)
920-
) + guides(colour = "none", linetype = "none")
919+
if (!is.null(nejm.surv.by)) {
920+
p2 <- p1 + coord_cartesian(ylim = nejm.infigure.ylim) + theme(
921+
axis.title.x = element_blank(), axis.title.y = element_blank(),
922+
axis.text = element_text(size = 10 * nejm.infigure.ratiow)
923+
) + guides(colour = "none", linetype = "none")+ scale_y_continuous(limits = nejm.infigure.ylim, breaks = seq(nejm.infigure.ylim[1], nejm.infigure.ylim[2], by = nejm.surv.by), labels = scale_labels)
924+
} else {
925+
p2 <- p1 + coord_cartesian(ylim = nejm.infigure.ylim) + theme(
926+
axis.title.x = element_blank(), axis.title.y = element_blank(),
927+
axis.text = element_text(size = 10 * nejm.infigure.ratiow) + scale_y_continuous(limits = nejm.infigure.ylim, breaks = waiver(), labels = scale_labels)
928+
) + guides(colour = "none", linetype = "none")
929+
}
930+
931+
921932
p <- p + patchwork::inset_element(p2, 1 - nejm.infigure.ratiow, 1 - nejm.infigure.ratioh, 1, 1, align_to = "panel")
922933
}
923934

man/jskm.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/svyjskm.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)