Kaplan-Meier Survival Curves

Kaplan-Meier survival analysis in R with the survival package β€” estimate curves by group, plot them, and compare with the log-rank test.

Time-to-event data β€” the backbone of clinical outcomes research.

Run the code

Everything in the video β€” edit it and press Run Code to run real R right here, or copy it:

Note

The first Run Code installs the packages this lesson needs (survival) into your browser session β€” give it 20–40 seconds.

Download this R script  Β·  β–Ά Open the full playground

When to use it. Use it to estimate and compare survival over time between groups. The log-rank test asks whether the curves differ; report median survival per group.

Read publication-quality Kaplan-Meier curves.

Next: Cox Proportional Hazards β†’