# How to make a Surv object and interpret censoring [closed]

So I have a data set with several different parameters, age, sex, etc. I also have an indicator of if any given subject has HIV or does not. I want to plot survival curves for these. I also have for each subject the time to death after diagnosis or the last time they were observed, and an indicator that tells us if they were censored or if they did indeed die.

So my question is, how do we account for censoring and how do we make a survival object that allows us to make separate estimates for survival for those who do have HIV and those who do not?

For example, my data is HIV.dataset

and I have some parameters,

HIV.dataset$gender, HIV.dataset\$hiv,

HIV.dataset\$ind and HIV.dataset\$time

Where the gender is a factorized version ie M or F. hiv is an indicator (1= HIV positive)

ind represents the indicator of death , 0 is censored and 1 is death

and time represents the time in days to death after diagnosis or the last time they were observed.

So I am not sure how I account for censoring. Is this something I include or do not include? How can I separate the cases to make separate curves, for example if I wanted a survival curve for those who do have HIV.

I know I should make use of survfit , and I would need a Surv object.

So in summary I am looking to better understand how to plot survival curves (using Kaplan-Meier Estimates) and how to account for censoring.

Thanks all

## closed as off-topic by whuber♦Nov 16 '18 at 21:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – whuber
If this question can be reworded to fit the rules in the help center, please edit the question.

sfit <- survfit(Surv(time, ind) ~ gender, data = HIV.dataset)