[R] Obtaining the first /or last record of a subject in a longitudinal study

Gabor Grothendieck ggrothendieck at gmail.com
Thu Aug 7 17:03:33 CEST 2008


It would have helped to see an example to clarify the input and
output to the problem but !duplicated(x) will be TRUE for the first
of each set of equal values in x and !duplicated(x, fromLast = TRUE)
for the last.  See ?duplicated for details.

On Thu, Aug 7, 2008 at 6:21 AM, Luwis Tapiwa Diya <siwulayid at gmail.com> wrote:
> Dear R users,
>
> I was wondering if anyone knows how to obtain(subset) the first and/or the
> last record of a subject in a longitudinal setup.
>
> Normally in SAS one uses first.variable1 and last.variable1. So my question
> is that is there an R way of doing this.
>
> Regards,
>
> --
> Luwis Diya, Phd student (Biostatistics),
> Biostatistical Center,
> School Of Public Health,
> Catholic University of Leuven,
> U.Z. St Raphael,
> Kapucijnenvoer 35,
> B-3000 Leuven,
> Belgium,
>
> Cell: +32(0)497 22 94 83
> Phone:+32(0)16 32 68 86 [Office]
> Phone:+32(0)16 32 98 76 [Home]
> Fax: +32(0)16 33 70 15
>
> Email: luwis.diya at med.kuleuven.be
> http://med.kuleuven.be/biostat/staff/LD.htm
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list