Skip to content

Commit 2151066

Browse files
committed
s
1 parent 33d4666 commit 2151066

File tree

7 files changed

+35
-13
lines changed

7 files changed

+35
-13
lines changed

DESCRIPTION

+2-2
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.3.0
4-
Date: 2019-02-15
3+
Version: 0.3.1
4+
Date: 2019-03-12
55
Authors@R: c(person("Jinseob", "Kim", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9403-605X")),
66
person("Zarathu", role = c("cph", "fnd"))
77
)

NEWS.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# jskm 0.3.1
2+
3+
## Update
4+
5+
* The p-value is expressed as the value rounded to the 3rd decimal place.
6+
7+
* Add **pval.testname** option, p-value is expressed with **(Log-rank)** text if **pval.testname == T**.
8+
19
# jskm 0.3.0
210

311
## New feature

R/jskm.R

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#' @param pval logical: add the pvalue to the plot?
1616
#' @param pval.size numeric value specifying the p-value text size. Default is 5.
1717
#' @param pval.coord numeric vector, of length 2, specifying the x and y coordinates of the p-value. Default values are NULL
18+
#' @param pval.testname logical: add '(Log-rank)' text to p-value. Default = F
1819
#' @param marks logical: should censoring marks be added?
1920
#' @param shape what shape should the censoring marks be, default is a vertical line
2021
#' @param legend logical. should a legend be added to the plot?
@@ -88,6 +89,7 @@ jskm <- function(sfit,
8889
pval = FALSE,
8990
pval.size = 5,
9091
pval.coord = c(NULL, NULL),
92+
pval.testname = F,
9193
marks = TRUE,
9294
shape = 3,
9395
legend = TRUE,
@@ -292,7 +294,10 @@ jskm <- function(sfit,
292294
pvalue <- summary(sdiff)$logtest["pvalue"]
293295
}
294296

295-
pvaltxt <- ifelse(pvalue < 0.0001,"p < 0.0001",paste("p =", signif(pvalue, 3)))
297+
pvaltxt <- ifelse(pvalue < 0.0001,"p < 0.0001",paste("p =", round(pvalue, 3)))
298+
299+
if (pval.testname) pvaltxt <- paste0(pvaltxt, " (Log-rank)")
300+
296301
# MOVE P-VALUE LEGEND HERE BELOW [set x and y]
297302
if (is.null(pval.coord)){
298303
p <- p + annotate("text",x = (as.integer(max(sfit$time)/5)), y = 0.1 + ylims[1],label = pvaltxt, size = pval.size)

R/svyjskm.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#' @param pval logical: add the pvalue to the plot?, Default: FALSE
1414
#' @param pval.size numeric value specifying the p-value text size. Default is 5.
1515
#' @param pval.coord numeric vector, of length 2, specifying the x and y coordinates of the p-value. Default values are NULL
16+
#' @param pval.testname logical: add '(Log-rank)' text to p-value. Default = F
1617
#' @param legend logical. should a legend be added to the plot? Default: TRUE
1718
#' @param ci logical. Should confidence intervals be plotted. Default = NULL
1819
#' @param legendposition numeric. x, y position of the legend if plotted. Default: c(0.85, 0.8)
@@ -56,6 +57,7 @@ svyjskm <- function(sfit,
5657
pval = FALSE,
5758
pval.size = 5,
5859
pval.coord = c(NULL, NULL),
60+
pval.testname = F,
5961
legend = TRUE,
6062
legendposition=c(0.85,0.8),
6163
ci = NULL,
@@ -224,7 +226,9 @@ svyjskm <- function(sfit,
224226
}
225227
pvalue <- sdiff$p.value
226228

227-
pvaltxt <- ifelse(pvalue < 0.0001,"p < 0.0001",paste("p =", signif(pvalue, 3)))
229+
pvaltxt <- ifelse(pvalue < 0.0001,"p < 0.0001",paste("p =", round(pvalue, 3)))
230+
if (pval.testname) pvaltxt <- paste0(pvaltxt, " (Log-rank)")
231+
228232
# MOVE P-VALUE LEGEND HERE BELOW [set x and y]
229233
if (is.null(pval.coord)){
230234
p <- p + annotate("text",x = (as.integer(max(sapply(sfit, function(x){max(x$time)/5})))), y = 0.1 + ylims[1],label = pvaltxt, size = pval.size)

man/jskm.Rd

+5-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/svyjskm.Rd

+7-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-km.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ test_that("Run jskm", {
1010
ystratalabs = c("Obs", "Lev", "Lev + 5FU"), ystrataname = "rx"), "gtable")
1111
expect_is(jskm(fit, timeby=500), "gg")
1212
expect_is(jskm(fit, timeby=500, main = "kaplan", xlabs = "time", ylabs = "Suvrival (%)", surv.scale = "percent"), "gg")
13-
expect_is(jskm(fit, pval.size = 7, pval.coord = c(100, 0.2)), "gg")
13+
expect_is(jskm(fit, pval.size = 7, pval.coord = c(100, 0.2), pval.testname = T), "gg")
1414
expect_is(jskm(fit, timeby=500, ci = T), "gg")
1515
expect_is(jskm(fit, timeby=500, legend = F), "gg")
1616
expect_is(jskm(fit, timeby=500, cumhaz = T), "gg")
@@ -39,7 +39,7 @@ test_that("Run svyjskm", {
3939
expect_is(svyjskm(s1, ci = F, cumhaz = T), "gg")
4040
s2 <- survey::svykm(Surv(time,status>0)~sex, design=dpbc, se = F)
4141
expect_is(svyjskm(s2, ci = F), "gg")
42-
expect_is(svyjskm(s2, design = dpbc, pval = T, pval.size = 7, pval.coord = c(100, 0.2)), "gg")
42+
expect_is(svyjskm(s2, design = dpbc, pval = T, pval.size = 7, pval.coord = c(100, 0.2), pval.testname = T), "gg")
4343
#pv <- svyjskm(s2, pval = T, design = dpbc)
4444
#expect_is(pv, "gg")
4545
expect_error(svyjskm(s2, ci = T))

0 commit comments

Comments
 (0)