Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/ggsurvplot_core.R
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,12 @@ ggsurvplot_core <- function(fit, data = NULL, fun = NULL,
h_line_data <- data.frame(x = 0, y = max(df$y2), xend = max(df$x1), yend = max(df$y2))
p <- p +
geom_segment(aes(x = .data$x, y = .data$y, xend = .data$xend, yend = .data$yend),
data = h_line_data, linetype = linetype, size = size, color = color) # horizontal segment
data = h_line_data, linetype = linetype, linewidth = size, color = color) # horizontal segment
}

if(type %in% c("hv", "v"))
p <- p + geom_segment(aes(x = .data$x1, y = .data$y1, xend = .data$x2, yend = .data$y2), data = df,
linetype = linetype, size = size, color = color) # vertical segments
linetype = linetype, linewidth = size, color = color) # vertical segments
}
else warning("Median survival not reached.")
}
Expand Down
2 changes: 1 addition & 1 deletion R/ggsurvplot_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ ggsurvplot_df <- function(fit, fun = NULL,
df[, .strata.var] <- factor( df[, .strata.var], levels = .levels(.strata), labels = legend.labs)

p <- ggplot2::ggplot(df, ggplot2::aes(x = !!sym("time"), y = !!sym("surv"))) +
ggpubr::geom_exec(surv.geom, data = df, size = size, color = color, linetype = linetype, ...) +
ggpubr::geom_exec(surv.geom, data = df, linewidth = size, color = color, linetype = linetype, ...) +
ggplot2::scale_y_continuous(breaks = y.breaks, labels = scale_labels, limits = ylim, expand = .expand) +
ggplot2::coord_cartesian(xlim = xlim)+
ggtheme
Expand Down
5 changes: 5 additions & 0 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ is_pkg_version_sup<- function(pkg, version){
cc
}

# shim for ggplot2 prior to 3.5.2
if (!exists("is_ggplot") && exists("is.ggplot")) {
is_ggplot <- is.ggplot
}

# Count the number of ggplots in a list
.count_ggplots <- function(list.objects){
nplot <- 0
Expand Down
25 changes: 25 additions & 0 deletions tests/testthat/test-ggsurvplot_basic.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
test_that("basic KM plot runs without {lifecycle} warnings", {
rlang::local_options(lifecycle_verbosity = "warning")

expect_no_warning(
{
ggsurvplot(
fit = survfit(Surv(time = time, event = status) ~ x, data = aml),
surv.median.line = "hv"
)
},
class = "lifecycle_warning_deprecated"
)
})

test_that("basic KM plot runs without {lifecycle} errors", {
expect_no_error(
{
ggsurvplot(
fit = survfit(Surv(time = time, event = status) ~ x, data = aml),
surv.median.line = "hv"
)
},
class = "lifecycle_error_deprecated"
)
})