I have a dataset as follows:
mydata <- read.table(header=TRUE, text="
Id DAYS QS Event
01 70 1 1
01 78 2 1
01 85 3 1
02 92 4 1
02 98 5 1
02 105 6 1
02 106 7 0
")
I would like to use the DAYS column to create a start and end column like this:
mydata <- read.table(header=TRUE, text="
Id start end QS Event
01 0 70 1 1
01 70 78 2 1
01 78 85 3 1
02 0 92 4 1
02 92 98 5 1
02 98 105 6 1
02 105 106 7 0
")
How can I do that?