Skip to content

Instantly share code, notes, and snippets.

@daynebatten
Created February 26, 2015 19:12
Show Gist options
  • Select an option

  • Save daynebatten/ef8458a2b02ac8fb5892 to your computer and use it in GitHub Desktop.

Select an option

Save daynebatten/ef8458a2b02ac8fb5892 to your computer and use it in GitHub Desktop.
# Load the survival library
library(survival)
# Read in the data and create a "survival object"
netlixx_rmst <- read.csv('C:/Users/dayne/Desktop/NetLixxRMST.csv')
netlixx_rmst$survival <- Surv(netlixx_rmst$time, netlixx_rmst$churned == 1)
# Fit a survival curve for each group
fitted <- survfit(survival ~ credit, data = netlixx_rmst)
# Get the 180-day RMST for each group
print(fitted, print.rmean=getOption("survfit.print.rmean"), rmean = 180)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment