Last active
August 29, 2015 14:15
-
-
Save daynebatten/00e190f3e1b7aef4b49a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use the survival library | |
library(survival) | |
# Read in the NetLixx data... yes, I use Windows. | |
net_lixx <- read.csv('C:/Users/dayne/Desktop/NetLixx.csv') | |
# Create a "survival object" for each observation, using time and churn data. | |
net_lixx$survival <- Surv(net_lixx$time, net_lixx$churned == 1) | |
# Fit a basic survival curve using the data | |
fit <- survfit(survival ~ 1, data = net_lixx) | |
# Plot the survival curve and add a title! | |
plot(fit, lty = 1, mark.time = FALSE, ylim=c(.75,1), xlab = 'Days since Subscribing', ylab = 'Percent Surviving') | |
title(main = 'NetLixx Survival Curve') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment