[R] using if statment and loops to create data layout of recurrent events
AVSHALO2 at POST.TAU.AC.IL
Sat Nov 13 13:17:13 CET 2010
I have a data set with recurrence time (up to four) of myocardial infarction
Part of the file is showing below:
Num1 Trt Sex Time T1 T2 T3 T4
1011 1 1 9
1211 0 1 59
3020 1 2 14 3
1245 0 1 18 12 16
3069 1 2 26 6 12 13
2051 0 1 53 3 15 46 51
The data consist of the following eight variables:
Num1 , patient number
Trt, treatment group (1=placebo and 2=drug)
Sex, Respondent Sex
Time, follow-up time
T1, T2, T3, and T4, times of the four potential recurrences of MI. A
patient with only two recurrences has missing values in T3 and T4.
In the data set, four observations should be created for each patient, one
for each of the four potential MI recurrences. In addition to values of Trt,
and Sex for the patient, each observation contains the following variables:
ID, patient’s identification (which is the sequence number of the subject)
Visit, visit number (with value k for the kth potential MI recurrence)
TStart, time of the (k–1)th recurrence for Visit=k, or the entry time 0 if
VISIT=1, or the follow-up time if the (k–1)th recurrence does not occur
TStop, time of the kth recurrence if Visit=k or follow-up time if the kth
recurrence does not occur
Status, event status of TStop (1=recurrence and 0=censored)
For instance, patient # 3 with only one recurrence time at month 3 who was
followed until month 14 will have values for Visit, TStart, TStop, and
Status of (1,0,3,1), (2,3,14,0), (3,14,14,0), and (4,14,14,0), respectively.
If the follow-up time is beyond the time of the fourth MI recurrence, you
must ignore it. Which means that even patient with 4 recurrence times has
only four rows.
How can I do it with R ?
Any suggestions will be more than welcome.
View this message in context: http://r.789695.n4.nabble.com/using-if-statment-and-loops-to-create-data-layout-of-recurrent-events-tp3040784p3040784.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help