Setting up data for Survival Analysis in R I am at the beginning of setting up a survival analysis in R.
I took a look in this book here: https://www.powells.com/book/modeling-survival-data-9780387987842/ but struggle to properly set the data up in the first place. So this is a very basic question to survival analysis as I can not find a good example online.
If there is a working example answering my question, a link is much appreciated!
#Survival analysis data set

ID<-c(2,3,1,2,3,1,2,3,1,3)
year<-c(1999,1999,2000,2000,2000,2001,2001,2001,2002,2002)
'simply random numbers 1-5 where 5 is the event'
x1<-c(4,3,2,1,4,5,3,2,1,5)
'x2 event dummy'
event<-ifelse(x1==5,1,0)

df<-data.frame(ID,year,x1,event)
df

From the reading I did I understand there has to be a censoring time. But what exactly is it?
Is this censoring time the time since observation started? Or just if the specific observation left the sample ? I.e.:
'Censoring time'
C1<-c(0,0,0,1,1,1,2,2,2,3)
C2<-c(rep(0,6),1,0,0,0)
df<-data.frame(ID,year,x1,event,C1,C2)
df

How do I deal with observations were the event occurred, but data is still available? For example in:
df[6,]
ID year x1 event C
1 2001  5     1  2

Lastly, there has to be a variable "time to event" or end of study like the following:
'Time to event/ end of study:'
t<-c(2,3,1,1,2,0,0,1,0,0)
df<-data.frame(ID,year,x1,event,C1,C2,t)
df

I am grateful for any insights/hints/ links etc 
 A: A censoring time is not a requirement. In engine reliability testing, for instance, all engines are usually stressed until they explode. But for cancer patients, they might not have had the event at the time of the analysis, or were otherwise lost to follow-up.
A censoring time is the latest time in the cohort study at which the subject was known to be at risk for the event. For this reason, we never know the event time when there's censoring (except that it must be past a certain point).
In a SURV object in R, the "event" time is the minimum of the event time and the censoring time.. a purely probabilistic construct to describe the data you ACTUALLY get. To designate whether that time was an actual event, or a censoring, you use the event indicator as a second argument to the SURV.
So for instance:
t <- c(10, 20)
i <- c(1, 0)
Surv(t, i)

Creates a surv object for 1 death event at time 10 and 1 censoring event at time 20.
By default, this is left censoring because it is the most common type of censoring. If there is right censoring ("time since the observation started"), you can input a time 1 and time 2 to the surv object where time 1 designates entry into the risk set. There are methods for interval censoring too.
