Skip to content

"conditional duplicates"?

3 messages · Christian Schulz, Dimitris Rizopoulos

#
Hi,

i would like check a repeated measurement dataset, whether
cases (which (id) could be more than one time included and not all same 
times included.)
have more than one times the same SMONTH!?

#This pseudo code didn't work with a for loop, because the [i+1] isn't 
known.
How i could refer to [i+1] ?

if(ID[i] == ID[i+1] & SMONTH[i] !=[i+1])  {res[i] <- 0 }
if(ID[i] == ID[i+1] & SMONTH[i] == [i+1]) {res[i] <- 1 }
 
many thanks,
christian
#
Hi Christian,

may be this is helpful:

dat <- data.frame(id=rep(1:4, each=5), smonth=sample(1:5, 20, TRUE))
dat$duplicated <- unlist(tapply(dat$smonth, dat$id, duplicated))
dat

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/396887
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Christian Schulz" <ozric at web.de>
To: <r-help at stat.math.ethz.ch>
Sent: Wednesday, November 10, 2004 1:52 PM
Subject: [R] "conditional duplicates"?
#
Many Thanks!
Dimitris Rizopoulos wrote: