I have quite a simple dataset:
ID Value Time
1 censored 1
1 censored 2
1 uncensored 3
1 uncensored 4
1 censored 5
1 censored 6
2 censored 1
2 uncensored 2
2 uncensored 3
2 uncensored 4
2 censored 5
I want to keep the first uncensored
occurrence, and I want to keep the first censored
occurrence after an uncensored
one. for example:
ID Value Time
1 uncensored 3
1 censored 5
2 uncensored 2
2 censored 5
Not everyone has their first censored date at time 5, that was just for an example.
Value
is a binary variable: 1 for censored, and 0 for uncensored, but I've labelled them.
Here's another possible
data.table
solutionOr similarly, using
which
instead ofmatch