I have event data on a population level, ie for each day there is a sum of individuals with events and individuals censored. I would like to expand this data to a more traditional format for survival analysis, ie each individual get a row. So for each day, a number of rows need to added for the number of events (with events = 1 and censor = 0) and for the number of censor (with events = 0 and censor = 1). Below is an example of an input data frame (dataIn) and of the desired output.
days <- c(1,2,3)
event <- c(2,2,0)
censor <- c(0,2,2)
dataIn <- data.frame(days, event, censor)
days event censor
1 2 0
2 2 2
3 0 2
days event censor
1 1 0
1 1 0
2 1 0
2 1 0
2 0 1
2 0 1
3 0 1
3 0 1