tests/testthat/test-ggsurvtable.R

context("test-ggsurvtable")

library(dplyr)
library("survival")
data("lung")
fit <- survfit(Surv(time, status) ~ sex, data = lung)

test_that("survtable y axis label colors work", {
  p <- ggrisktable(fit, data = lung, color = "strata")
  .build <- ggplot_build(p)
  .build_data <- .build$data[[1]]
  .table <- .build_data[, c("colour", "y")] %>%
    dplyr::distinct()
  expect_equal(.table$colour, c("#F8766D", "#00BFC4"))
  expect_equal(as.numeric(.table$y), c(2, 1))
})

Try the survminer package in your browser

Any scripts or data that you put into this service are public.

survminer documentation built on March 9, 2021, 5:07 p.m.