R script for survival