[R] "conditional duplicates"?

Christian Schulz ozric at web.de
Wed Nov 10 14:27:07 CET 2004


Many Thanks!

Dimitris Rizopoulos wrote:

> 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"?
>
>
>> 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
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! 
>> http://www.R-project.org/posting-guide.html
>>
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list