diff --git a/R/svyjskm.R b/R/svyjskm.R index ba5c516..3b25272 100644 --- a/R/svyjskm.R +++ b/R/svyjskm.R @@ -37,13 +37,13 @@ #' @return plot #' @details DETAILS #' @examples -# library(survey) -# data(pbc, package = "survival") -# pbc$randomized <- with(pbc, !is.na(trt) & trt > 0) -# biasmodel <- glm(randomized ~ age * edema, data = pbc) -# pbc$randprob <- fitted(biasmodel) -# dpbc <- svydesign(id = ~1, prob = ~randprob, strata = ~edema, data = subset(pbc, randomized)) -# s1 <- svykm(Surv(time, status > 0) ~ sex, design = dpbc) +#' library(survey) +#' data(pbc, package = "survival") +#' pbc$randomized <- with(pbc, !is.na(trt) & trt > 0) +#' biasmodel <- glm(randomized ~ age * edema, data = pbc) +#' pbc$randprob <- fitted(biasmodel) +#' dpbc <- svydesign(id = ~1, prob = ~randprob, strata = ~edema, data = subset(pbc, randomized)) +#' s1 <- svykm(Surv(time, status > 0) ~ sex, design = dpbc) #' svyjskm(s1) #' @rdname svyjskm #' @import ggplot2 @@ -89,7 +89,7 @@ svyjskm <- function(sfit, nejm.infigure.ylim = c(0, 1), ...) { surv <- strata <- lower <- upper <- NULL - + if (!is.null(theme) && theme == "nejm") legendposition <- legendposition if (is.null(timeby)) { if (inherits(sfit, "svykmlist")) { @@ -100,7 +100,7 @@ svyjskm <- function(sfit, timeby <- signif(max(sfit$time) / 7, 1) } } - + if (is.null(ci)) { if (inherits(sfit, "svykmlist")) { ci <- "varlog" %in% names(sfit[[1]]) @@ -108,8 +108,8 @@ svyjskm <- function(sfit, ci <- "varlog" %in% names(sfit) } } - - + + if (ci & !is.null(cut.landmark)) { if (is.null(design)) { design <- tryCatch(get(as.character(attr(sfit, "call")$design)), error = function(e) e) @@ -125,20 +125,20 @@ svyjskm <- function(sfit, "warning" %in% class(tryCatch(as.numeric(x), warning = function(w) w)) })] } - + design1 <- design design1$variables[[var.event]][design1$variables[[var.time]] >= cut.landmark] <- 0 design1$variables[[var.time]][design1$variables[[var.time]] >= cut.landmark] <- cut.landmark - + sfit2 <- survey::svykm(formula(sfit), design = subset(design, get(var.time) >= cut.landmark), se = T) } - - - - + + + + if (inherits(sfit, "svykmlist")) { if (is.null(ystrataname)) ystrataname <- as.character(formula(sfit)[[3]]) - + if (ci) { if ("varlog" %in% names(sfit[[1]])) { if (!is.null(cut.landmark)) { @@ -150,12 +150,12 @@ svyjskm <- function(sfit, })) df <- rbind(df[df$time < cut.landmark, ], data.frame("strata" = unique(df$strata), "time" = cut.landmark, "surv" = 1, "lower" = 1, "upper" = 1), df2) } else { - if (med == TRUE) { + if (med == TRUE){ df <- do.call(rbind, lapply(names(sfit), function(x) { df2 <- data.frame("strata" = x, "time" = sfit[[x]]$time, "surv" = sfit[[x]]$surv, "lower" = pmax(0, exp(log(sfit[[x]]$surv) - 1.96 * sqrt(sfit[[x]]$varlog))), "upper" = pmin(1, exp(log(sfit[[x]]$surv) + 1.96 * sqrt(sfit[[x]]$varlog)))) - valid_indices <- which(df2$surv <= 0.5) + valid_indices <- which(df2$surv <= 0.5) closest_index <- valid_indices[which.min(abs(df2$surv[valid_indices] - 0.5))] - df2$med <- df2[closest_index, "time"] + df2$med <- df2[closest_index,"time"] return(df2) })) } else { @@ -166,8 +166,8 @@ svyjskm <- function(sfit, } } else { stop("No CI information in svykmlist object. please run svykm with se = T option.") - } - } else { + } + }else { if (!is.null(cut.landmark)) { df <- do.call(rbind, lapply(names(sfit), function(x) { data.frame("strata" = x, "time" = sfit[[x]]$time, "surv" = sfit[[x]]$surv) @@ -178,37 +178,36 @@ svyjskm <- function(sfit, } else { df[df$time == cut.landmark & df$strata == v, "surv"] <- 1 } - + df[df$time > cut.landmark & df$strata == v, "surv"] <- df[df$time > cut.landmark & df$strata == v, "surv"] / min(df[df$time < cut.landmark & df$strata == v, "surv"]) } } else { - if (med == TRUE) { + if (med == TRUE){ df <- do.call(rbind, lapply(names(sfit), function(x) { df2 <- data.frame("strata" = x, "time" = sfit[[x]]$time, "surv" = sfit[[x]]$surv) - valid_indices <- which(df2$surv <= 0.5) + valid_indices <- which(df2$surv <= 0.5) closest_index <- valid_indices[which.min(abs(df2$surv[valid_indices] - 0.5))] - df2$med <- df2[closest_index, "time"] + df2$med <- df2[closest_index,"time"] return(df2) - })) - } else { - df <- do.call(rbind, lapply(names(sfit), function(x) { - data.frame("strata" = x, "time" = sfit[[x]]$time, "surv" = sfit[[x]]$surv) - })) - } + }))} else { + df <- do.call(rbind, lapply(names(sfit), function(x) { + data.frame("strata" = x, "time" = sfit[[x]]$time, "surv" = sfit[[x]]$surv) + })) + } } } - + df$strata <- factor(df$strata, levels = names(sfit)) times <- seq(0, max(sapply(sfit, function(x) { max(x$time) })), by = timeby) if (is.null(ystratalabs)) { - df3 <- df[-c(1, 2), ] + df3 <- df[-c(1,2),] ystratalabs <- levels(df$strata) - if (med == TRUE) { - ystratalabs2 <- NULL + if (med == TRUE){ + ystratalabs2 <-NULL for (i in 1:length(names(sfit))) { - median_time <- df3[df3$strata == names(sfit)[[i]], "med"] %>% unique() + median_time <- unique(df3[df3$strata == names(sfit)[[i]], "med"]) ystratalabs2 <- c(ystratalabs2, paste0(ystratalabs[[i]], " (median : ", median_time, ")")) } } @@ -220,7 +219,7 @@ svyjskm <- function(sfit, } } else if (inherits(sfit, "svykm")) { if (is.null(ystrataname)) ystrataname <- "Strata" - + if (ci) { if ("varlog" %in% names(sfit)) { if (!is.null(cut.landmark)) { @@ -228,11 +227,11 @@ svyjskm <- function(sfit, df2 <- data.frame("strata" = "All", "time" = sfit2$time, "surv" = sfit2$surv, "lower" = pmax(0, exp(log(sfit2$surv) - 1.96 * sqrt(sfit2$varlog))), "upper" = pmax(0, exp(log(sfit2$surv) + 1.96 * sqrt(sfit2$varlog)))) df <- rbind(df[df$time < cut.landmark, ], data.frame("strata" = "All", "time" = cut.landmark, "surv" = 1, "lower" = 1, "upper" = 1), df2) } else { - if (med == T) { + if (med == T){ df <- data.frame("strata" = "All", "time" = sfit$time, "surv" = sfit$surv, "lower" = pmax(0, exp(log(sfit$surv) - 1.96 * sqrt(sfit$varlog))), "upper" = pmax(0, exp(log(sfit$surv) + 1.96 * sqrt(sfit$varlog)))) valid_indices <- which(df$surv <= 0.5) closest_index <- valid_indices[which.min(abs(df$surv[valid_indices] - 0.5))] - df$med <- df[closest_index, "time"] + df$med <- df[closest_index,"time"] } else { df <- data.frame("strata" = "All", "time" = sfit$time, "surv" = sfit$surv, "lower" = pmax(0, exp(log(sfit$surv) - 1.96 * sqrt(sfit$varlog))), "upper" = pmax(0, exp(log(sfit$surv) + 1.96 * sqrt(sfit$varlog)))) } @@ -248,20 +247,20 @@ svyjskm <- function(sfit, } else { df[df$time == cut.landmark, "surv"] <- 1 } - + df[df$time > cut.landmark, "surv"] <- df[df$time > cut.landmark, "surv"] / min(df[df$time < cut.landmark, "surv"]) - } else { - if (med == T) { + } else{ + if (med == T){ df <- data.frame("strata" = "All", "time" = sfit$time, "surv" = sfit$surv) valid_indices <- which(df$surv <= 0.5) closest_index <- valid_indices[which.min(abs(df$surv[valid_indices] - 0.5))] - df$med <- df[closest_index, "time"] + df$med <- df[closest_index,"time"] } else { df <- data.frame("strata" = "All", "time" = sfit$time, "surv" = sfit$surv) } } } - + times <- seq(0, max(sfit$time), by = timeby) if (is.null(ystratalabs)) { ystratalabs <- "All" @@ -271,13 +270,13 @@ svyjskm <- function(sfit, xlims <- c(0, max(sfit$time)) } } - + m <- max(nchar(ystratalabs)) - - - - - + + + + + if (cumhaz) { df$surv <- 1 - df$surv if (ci) { @@ -287,18 +286,18 @@ svyjskm <- function(sfit, df$upper <- upper.new } } - + # Final changes to data for survival plot levels(df$strata) <- ystratalabs - zeros <- if (med == T & is.null(cut.landmark)) { + zeros <- if (med == T & is.null(cut.landmark)){ data.frame("strata" = factor(ystratalabs, levels = levels(df$strata)), "time" = 0, "surv" = 1, "med" = 0.5) } else { data.frame("strata" = factor(ystratalabs, levels = levels(df$strata)), "time" = 0, "surv" = 1) } - + if (ci) { - if (med == T & is.null(cut.landmark)) { - zeros$med <- NULL + if (med == T & is.null(cut.landmark)){ + zeros$med <- NULL zeros$upper <- 1 zeros$lower <- 1 zeros$med <- 0.5 @@ -314,27 +313,27 @@ svyjskm <- function(sfit, zeros$upper <- 0 } } - + df <- rbind(zeros, df) d <- length(levels(df$strata)) - + ################################### # specifying axis parameteres etc # ################################### - + if (dashed == TRUE | all(linecols == "black")) { linetype <- c("solid", "dashed", "dotted", "dotdash", "longdash", "twodash", "1F", "F1", "4C88C488", "12345678") } else { linetype <- c("solid", "solid", "solid", "solid", "solid", "solid", "solid", "solid", "solid", "solid", "solid") } - + # Scale transformation # :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: surv.scale <- match.arg(surv.scale) scale_labels <- ggplot2::waiver() if (surv.scale == "percent") scale_labels <- scales::percent - - + + p <- ggplot2::ggplot(df, aes(x = time, y = surv, colour = strata, linetype = strata)) + ggtitle(main) linecols2 <- linecols @@ -343,7 +342,7 @@ svyjskm <- function(sfit, p <- ggplot2::ggplot(df, aes(x = time, y = surv, linetype = strata)) + ggtitle(main) } - + # Set up theme elements p <- p + theme_bw() + theme( @@ -361,7 +360,7 @@ svyjskm <- function(sfit, ) + scale_x_continuous(xlabs, breaks = times, limits = xlims) + scale_y_continuous(ylabs, limits = ylims, labels = scale_labels) - + if (!is.null(theme) && theme == "jama") { p <- p + theme( panel.grid.major.x = element_blank() @@ -371,16 +370,16 @@ svyjskm <- function(sfit, panel.grid.major = element_blank() ) } - - + + # Removes the legend: if (legend == FALSE) { p <- p + guides(colour = "none", linetype = "none") } - + # Add lines too plot if (is.null(cut.landmark)) { - if (med == T) { + if (med == T){ p <- p + geom_step(linewidth = linewidth) + scale_linetype_manual(name = ystrataname, values = linetype, labels = ystratalabs2) } else { @@ -391,32 +390,32 @@ svyjskm <- function(sfit, p <- p + geom_step(data = subset(df, time < cut.landmark), linewidth = linewidth) + geom_step(data = subset(df, time >= cut.landmark), linewidth = linewidth) + scale_linetype_manual(name = ystrataname, values = linetype, labels = ystratalabs) } - - + + # Add median value - if (med == TRUE & is.null(cut.landmark)) { - df3 <- df[-c(1, 2), ] + if (med == TRUE & is.null(cut.landmark)){ + df3 <- df[-c(1,2),] if (inherits(sfit, "svykm")) { - median_time <- df3$med %>% unique() - if (!is.na(median_time)) { - p <- p + annotate("segment", x = xlims[1], xend = median_time, y = 0.5, yend = 0.5, linewidth = 0.3, linetype = "dashed") + annotate("segment", x = median_time, xend = median_time, y = ylims[1], yend = 0.5, linewidth = 0.3, linetype = "dashed") - } + median_time <- unique(df3$med) + + if(!is.na(median_time)) + p <- p + annotate("segment", x = xlims[1], xend = median_time, y = 0.5, yend = 0.5, linewidth = 0.3, linetype = "dashed") + annotate("segment", x = median_time, xend = median_time, y = ylims[1], yend = 0.5, linewidth = 0.3, linetype = "dashed") } else { - for (i in 1:length(names(sfit))) { - median_time <- df3[df3$strata == names(sfit)[[i]], "med"] %>% unique() - if (!is.na(median_time)) { + for (i in 1:length(names(sfit))){ + median_time <- unique(df3[df3$strata == names(sfit)[[i]], "med"]) + if(!is.na(median_time)){ p <- p + annotate("segment", x = xlims[1], xend = median_time, y = 0.5, yend = 0.5, linewidth = 0.3, linetype = "dashed") + annotate("segment", x = median_time, xend = median_time, y = ylims[1], yend = 0.5, linewidth = 0.3, linetype = "dashed") } } } } - + brewer.palette <- c( "BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", "RdYlBu", "RdYlGn", "Spectral", "Accent", "Dark2", "Paired", "Pastel1", "Pastel2", "Set1", "Set2", "Set3", "Blues", "BuGn", "BuPu", "GnBu", "Greens", "Greys", "Oranges", "OrRd", "PuBu", "PuBuGn", "PuRd", "Purples", "RdPu", "Reds", "YlGn", "YlGnBu", "YlOrBr", "YlOrRd" ) - + if (!is.null(theme) && theme == "jama") { col.pal <- c("#00AFBB", "#E7B800", "#FC4E07") col.pal <- rep(col.pal, ceiling(length(ystratalabs) / 3)) @@ -437,10 +436,10 @@ svyjskm <- function(sfit, # } else { # p <- p + scale_color_manual(name = ystrataname, values = col.pal) # } } - - + + if (is.null(cut.landmark)) { - if (med == T) { + if (med == T){ if (is.null(col.pal)) { p <- p + scale_colour_brewer(name = ystrataname, palette = linecols, labels = ystratalabs2) } else { @@ -461,8 +460,8 @@ svyjskm <- function(sfit, } } # Add 95% CI to plot - - + + if (ci == TRUE) { if (med == TRUE & is.null(cut.landmark)) { if (all(linecols2 == "black")) { @@ -482,11 +481,11 @@ svyjskm <- function(sfit, } } } - + if (!is.null(cut.landmark)) { p <- p + geom_vline(xintercept = cut.landmark, lty = 2) } - + p1 <- p ## p-value if (inherits(sfit, "svykm")) pval <- FALSE @@ -517,14 +516,14 @@ svyjskm <- function(sfit, stop("'pval' option requires design object. please input 'design' option") } } - + if (is.null(cut.landmark)) { sdiff <- survey::svylogrank(formula(sfit), design = design) pvalue <- sdiff[[2]][2] - + pvaltxt <- ifelse(pvalue < 0.001, "p < 0.001", paste("p =", round(pvalue, 3))) if (pval.testname) pvaltxt <- paste0(pvaltxt, " (Log-rank)") - + # MOVE P-VALUE LEGEND HERE BELOW [set x and y] if (is.null(pval.coord)) { p <- p + annotate("text", x = as.integer(max(sapply(sfit, function(x) { @@ -551,16 +550,16 @@ svyjskm <- function(sfit, design1 <- design design1$variables[[var.event]][design1$variables[[var.time]] >= cut.landmark] <- 0 design1$variables[[var.time]][design1$variables[[var.time]] >= cut.landmark] <- cut.landmark - + sdiff1 <- survey::svylogrank(formula(sfit), design = design1) sdiff2 <- survey::svylogrank(formula(sfit), design = subset(design, get(var.time) >= cut.landmark)) pvalue <- sapply(list(sdiff1, sdiff2), function(x) { x[[2]][2] }) - + pvaltxt <- ifelse(pvalue < 0.001, "p < 0.001", paste("p =", round(pvalue, 3))) if (pval.testname) pvaltxt <- paste0(pvaltxt, " (Log-rank)") - + if (is.null(pval.coord)) { p <- p + annotate("text", x = c(as.integer(max(sapply(sfit, function(x) { max(x$time) / 10 @@ -572,11 +571,11 @@ svyjskm <- function(sfit, } } } - - - - - + + + + + ## Create a blank plot for place-holding blank.pic <- ggplot(df, aes(time, surv)) + geom_blank() + @@ -587,11 +586,11 @@ svyjskm <- function(sfit, axis.ticks = element_blank(), panel.grid.major = element_blank(), panel.border = element_blank() ) - + ################################################### # Create table graphic to include at-risk numbers # ################################################### - + n.risk <- NULL if (table == TRUE) { if (is.null(design)) { @@ -599,9 +598,9 @@ svyjskm <- function(sfit, } else { sfit2 <- survival::survfit(formula(sfit), data = design$variables) } - + # times <- seq(0, max(sfit2$time), by = timeby) - + if (is.null(subs)) { if (length(levels(summary(sfit2)$strata)) == 0) { subs1 <- 1 @@ -631,27 +630,27 @@ svyjskm <- function(sfit, subs2 <- which(regexpr(ssvar, summary(sfit2, censored = T)$strata, perl = T) != -1) subs3 <- which(regexpr(ssvar, summary(sfit2, times = times, extend = TRUE)$strata, perl = T) != -1) } - + if (!is.null(subs)) pval <- FALSE - - - + + + if (length(levels(summary(sfit2)$strata)) == 0) { Factor <- factor(rep("All", length(subs3))) } else { Factor <- factor(summary(sfit2, times = times, extend = TRUE)$strata[subs3]) } - - + + risk.data <- data.frame( strata = Factor, time = summary(sfit2, times = times, extend = TRUE)$time[subs3], n.risk = summary(sfit2, times = times, extend = TRUE)$n.risk[subs3] ) - - + + risk.data$strata <- factor(risk.data$strata, levels = rev(levels(risk.data$strata))) - + data.table <- ggplot(risk.data, aes(x = time, y = strata, label = format(n.risk, nsmall = 0))) + geom_text(size = 3.5) + theme_bw() + @@ -667,32 +666,31 @@ svyjskm <- function(sfit, axis.ticks = element_blank(), axis.text.y = element_text(face = "bold", hjust = 1) ) data.table <- data.table + - guides(colour = "none", linetype = "none") + xlab(NULL) + ylab(NULL) - - + guides(colour = "none", linetype = "none")+ xlab(NULL) + ylab(NULL) + + # ADJUST POSITION OF TABLE FOR AT RISK data.table <- data.table + theme(plot.margin = unit(c(-1.5, 1, 0.1, ifelse(m < 10, 3.1, 4.3) - 0.38 * m), "lines")) } - + ####################### # Plotting the graphs # ####################### if (!is.null(theme) && theme == "nejm") { - p2 <- p1 + coord_cartesian(ylim = nejm.infigure.ylim) + theme( - axis.title.x = element_blank(), axis.title.y = element_blank(), - axis.text = element_text(size = 10 * nejm.infigure.ratiow) + p2 <- p1 + coord_cartesian(ylim = nejm.infigure.ylim) + theme(axis.title.x = element_blank(), axis.title.y = element_blank(), + axis.text = element_text(size = 10 * nejm.infigure.ratiow) ) + guides(colour = "none", linetype = "none") p <- p + patchwork::inset_element(p2, 1 - nejm.infigure.ratiow, 1 - nejm.infigure.ratioh, 1, 1, align_to = "panel") } - + if (table == TRUE) { ggpubr::ggarrange(p, blank.pic, data.table, - nrow = 3, - # align = "v", - heights = c(2, .1, .25) + nrow = 3, + # align = "v", + heights = c(2, .1, .25) ) } else { p } -} +} \ No newline at end of file diff --git a/README.Rmd b/README.Rmd index 4bf1d46..f1bedd6 100644 --- a/README.Rmd +++ b/README.Rmd @@ -134,3 +134,4 @@ svyjskm(s2, theme = "jama", pval = T, table = T, design = dpbc) ```{r} svyjskm(s2, theme = "nejm", nejm.infigure.ratiow = 0.45, nejm.infigure.ratioh = 0.4, nejm.infigure.ylim = c(0.2, 1), pval = T, table = T, design = dpbc) ``` + diff --git a/man/figures/README-unnamed-chunk-1-1.png b/man/figures/README-unnamed-chunk-1-1.png index 09a313c..47b2b7e 100644 Binary files a/man/figures/README-unnamed-chunk-1-1.png and b/man/figures/README-unnamed-chunk-1-1.png differ diff --git a/man/figures/README-unnamed-chunk-1-2.png b/man/figures/README-unnamed-chunk-1-2.png index a4056a9..98cceb7 100644 Binary files a/man/figures/README-unnamed-chunk-1-2.png and b/man/figures/README-unnamed-chunk-1-2.png differ diff --git a/man/figures/README-unnamed-chunk-10-1.png b/man/figures/README-unnamed-chunk-10-1.png index 34206c2..a9c3ffd 100644 Binary files a/man/figures/README-unnamed-chunk-10-1.png and b/man/figures/README-unnamed-chunk-10-1.png differ diff --git a/man/figures/README-unnamed-chunk-2-1.png b/man/figures/README-unnamed-chunk-2-1.png index 387626b..3095458 100644 Binary files a/man/figures/README-unnamed-chunk-2-1.png and b/man/figures/README-unnamed-chunk-2-1.png differ diff --git a/man/figures/README-unnamed-chunk-3-1.png b/man/figures/README-unnamed-chunk-3-1.png index 6e566b6..a0a1b92 100644 Binary files a/man/figures/README-unnamed-chunk-3-1.png and b/man/figures/README-unnamed-chunk-3-1.png differ diff --git a/man/figures/README-unnamed-chunk-3-2.png b/man/figures/README-unnamed-chunk-3-2.png index 89ec847..056c12b 100644 Binary files a/man/figures/README-unnamed-chunk-3-2.png and b/man/figures/README-unnamed-chunk-3-2.png differ diff --git a/man/figures/README-unnamed-chunk-4-1.png b/man/figures/README-unnamed-chunk-4-1.png index d11787e..00e602e 100644 Binary files a/man/figures/README-unnamed-chunk-4-1.png and b/man/figures/README-unnamed-chunk-4-1.png differ diff --git a/man/figures/README-unnamed-chunk-4-2.png b/man/figures/README-unnamed-chunk-4-2.png index 3127387..e46042e 100644 Binary files a/man/figures/README-unnamed-chunk-4-2.png and b/man/figures/README-unnamed-chunk-4-2.png differ diff --git a/man/figures/README-unnamed-chunk-5-1.png b/man/figures/README-unnamed-chunk-5-1.png index 1584e30..421dd0e 100644 Binary files a/man/figures/README-unnamed-chunk-5-1.png and b/man/figures/README-unnamed-chunk-5-1.png differ diff --git a/man/figures/README-unnamed-chunk-6-1.png b/man/figures/README-unnamed-chunk-6-1.png index b32fb7f..421dd0e 100644 Binary files a/man/figures/README-unnamed-chunk-6-1.png and b/man/figures/README-unnamed-chunk-6-1.png differ diff --git a/man/figures/README-unnamed-chunk-7-1.png b/man/figures/README-unnamed-chunk-7-1.png index 30eca51..6d2c2cd 100644 Binary files a/man/figures/README-unnamed-chunk-7-1.png and b/man/figures/README-unnamed-chunk-7-1.png differ diff --git a/man/figures/README-unnamed-chunk-7-2.png b/man/figures/README-unnamed-chunk-7-2.png index b080e9e..a9c3ffd 100644 Binary files a/man/figures/README-unnamed-chunk-7-2.png and b/man/figures/README-unnamed-chunk-7-2.png differ diff --git a/man/figures/README-unnamed-chunk-7-3.png b/man/figures/README-unnamed-chunk-7-3.png index 4a0b555..49c111a 100644 Binary files a/man/figures/README-unnamed-chunk-7-3.png and b/man/figures/README-unnamed-chunk-7-3.png differ diff --git a/man/figures/README-unnamed-chunk-8-1.png b/man/figures/README-unnamed-chunk-8-1.png index 5996957..4fe5c9e 100644 Binary files a/man/figures/README-unnamed-chunk-8-1.png and b/man/figures/README-unnamed-chunk-8-1.png differ diff --git a/man/figures/README-unnamed-chunk-8-2.png b/man/figures/README-unnamed-chunk-8-2.png index 3ffb0d6..8e69266 100644 Binary files a/man/figures/README-unnamed-chunk-8-2.png and b/man/figures/README-unnamed-chunk-8-2.png differ diff --git a/man/figures/README-unnamed-chunk-8-3.png b/man/figures/README-unnamed-chunk-8-3.png index 7d2477d..370e241 100644 Binary files a/man/figures/README-unnamed-chunk-8-3.png and b/man/figures/README-unnamed-chunk-8-3.png differ diff --git a/man/figures/README-unnamed-chunk-9-1.png b/man/figures/README-unnamed-chunk-9-1.png index 37b0d8b..a9c3ffd 100644 Binary files a/man/figures/README-unnamed-chunk-9-1.png and b/man/figures/README-unnamed-chunk-9-1.png differ diff --git a/man/jskm.Rd b/man/jskm.Rd index 7877798..6480983 100644 --- a/man/jskm.Rd +++ b/man/jskm.Rd @@ -12,7 +12,7 @@ jskm( xlims = c(0, max(sfit$time)), ylims = c(0, 1), surv.scale = c("default", "percent"), - ystratalabs = names(sfit$strata), + ystratalabs = NULL, ystrataname = "Strata", timeby = signif(max(sfit$time)/7, 1), main = "", @@ -22,6 +22,7 @@ jskm( pval.testname = F, marks = TRUE, shape = 3, + med = FALSE, legend = TRUE, legendposition = c(0.85, 0.8), ci = FALSE, @@ -80,6 +81,8 @@ jskm( \item{shape}{what shape should the censoring marks be, default is a vertical line} +\item{med}{should a median line be added to the plot? Default = F} + \item{legend}{logical. should a legend be added to the plot?} \item{legendposition}{numeric. x, y position of the legend if plotted. Default=c(0.85,0.8)} diff --git a/man/svyjskm.Rd b/man/svyjskm.Rd index 5a5548b..1062314 100644 --- a/man/svyjskm.Rd +++ b/man/svyjskm.Rd @@ -20,6 +20,7 @@ svyjskm( pval.size = 5, pval.coord = c(NULL, NULL), pval.testname = F, + med = FALSE, legend = TRUE, legendposition = c(0.85, 0.8), ci = NULL, @@ -71,9 +72,11 @@ svyjskm( \item{pval.testname}{logical: add '(Log-rank)' text to p-value. Default = F} -\item{legend}{logical. should a legend be added to the plot? Default: TRUE} +\item{med}{should a median line be added to the plot? Default = F} -\item{legendposition}{numeric. x, y position of the legend if plotted. Default: c(0.85, 0.8)} +\item{legend}{logical. should a legend be added to the plot?} + +\item{legendposition}{numeric. x, y position of the legend if plotted. Default=c(0.85,0.8)} \item{ci}{logical. Should confidence intervals be plotted. Default = NULL}