MyNixOS website logo
Description

KMunicate-Style Kaplan–Meier Plots.

Produce Kaplan–Meier plots in the style recommended following the KMunicate study by Morris et al. (2019) <doi:10.1136/bmjopen-2019-030215>. The KMunicate style consists of Kaplan-Meier curves with confidence intervals to quantify uncertainty and an extended risk table (per treatment arm) depicting the number of study subjects at risk, events, and censored observations over time. The resulting plots are built using 'ggplot2' and can be further customised to a certain extent, including themes, fonts, and colour scales.

KMunicate-Style Kaplan–Meier Plots

Codecov testcoverage CRANstatus CRAN_Logs_Badge CRAN_Logs_Badge_Total R-CMD-check

The goal of {KMunicate} is to produce Kaplan–Meier plots in the style recommended following the KMunicate study (TP Morris et al. Proposals on Kaplan–Meier plots in medical research and a survey of stakeholder views: KMunicate. BMJ Open, 2019, 9:e030215).

Installation

You can install {KMunicate} from CRAN by typing the following in your R console:

install.packages("KMunicate")

Alternatively, you can install the dev version of {KMunicate} from GitHub with:

# install.packages("devtools")
devtools::install_github("ellessenne/KMunicate-package")

Example

library(survival)
library(KMunicate)

The {KMunicate} package comes with a couple of bundled dataset, cancer and brcancer. The main function is named KMunicate:

KM <- survfit(Surv(rectime, censrec) ~ hormon, data = brcancer)
time_scale <- seq(0, max(brcancer$rectime), by = 365)
KMunicate(fit = KM, time_scale = time_scale)
KM <- survfit(Surv(studytime, died) ~ drug, data = cancer2)
time_scale <- seq(0, max(cancer2$studytime), by = 7)
KMunicate(fit = KM, time_scale = time_scale)

You also might wonder, does this work with a single arm? Yes, yes it does:

KM <- survfit(Surv(studytime, died) ~ 1, data = cancer2)
time_scale <- seq(0, max(cancer2$studytime), by = 7)
KMunicate(fit = KM, time_scale = time_scale)

Finally, you can also plot 1 - survival by using the argument .reverse = TRUE:

KM <- survfit(Surv(rectime, censrec) ~ hormon, data = brcancer)
time_scale <- seq(0, max(brcancer$rectime), by = 365)
KMunicate(fit = KM, time_scale = time_scale, .reverse = TRUE)

Customise Risk Table

By default, KMunicate() will build a risk table conform to the KMunicate style, e.g., with cumulative number of events and censored (the column-wise sum is equal to the total number of individuals at risk per arm):

KM <- survfit(Surv(rectime, censrec) ~ hormon, data = brcancer)
time_scale <- seq(0, max(brcancer$rectime), by = 365)
KMunicate(fit = KM, time_scale = time_scale)

Alternatively, it is possible to customise the risk table via the .risk_table argument. For instance, if one wants to have interval-wise number of events and censored, just pass the survfit value to the .risk_table argument:

KMunicate(fit = KM, time_scale = time_scale, .risk_table = "survfit")

This is the default output of the summary.survfit() function.

Finally, it is also possible to fully omit the risk table by setting .risk_table = NULL:

KMunicate(fit = KM, time_scale = time_scale, .risk_table = NULL)

Custom Fonts

Assuming you have set up your computer to use custom fonts with ggplot2, customising your KMunicate-style plot is trivial. All you have to do is pass the font name as the .ff argument:

KM <- survfit(Surv(studytime, died) ~ 1, data = cancer2)
time_scale <- seq(0, max(cancer2$studytime), by = 7)
KMunicate(fit = KM, time_scale = time_scale, .ff = "Times New Roman")

Further Customisation

Several options to further customise each plot are provided, see e.g. the introductory vignette for more details.

Metadata

Version

0.2.5

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows