Skip to content
Prev 318177 / 398502 Next

Selecting First Incidence from Longitudinal Data

Hello,

You can use ?aggregate and ?head to do what you want. Try the following.



dat <- read.table(text="
ID    COMPL  SEX  HEREDITY
1    0      1      2
1    0      1      2
1    3      1      2
2    0      0      1
2    1      0      1
2    2      0      1
2    2      0      1
3    0      0      1
3    0      0      1
3    0      0      1
3    0      0      1
3    2      0      1
4    0      1      2
4    0      1      2
", header = TRUE)

aggregate(. ~ ID, data = subset(dat, COMPL != 0), head, 1)


Hope this helps,

Rui Barradas

Em 23-02-2013 14:28, Tasnuva Tabassum escreveu: