Skip to content
Prev 178016 / 398502 Next

Count Code

Many thanks for this, I will try this code.  Much appreciated.

-----Original Message-----
From: Peter Dalgaard [mailto:p.dalgaard at biostat.ku.dk] 
Sent: 22 April 2009 22:05
To: David Winsemius
Cc: Bronagh Grimes; r-help at r-project.org
Subject: Re: [R] Count Code
David Winsemius wrote:
I think this one could be

count <- ave(a1$subject_id, a1$subject_id, FUN = seq_along)

(assuming that "count+1;" increases the value from the previous record.)