Thank you very much!

This does indeed what I am looking for and really have R-ish look and feel.
I just have turned that into a little handy function 'replicates'

Best wishes,

Eric



2007/12/19, Henrique Dallazuanna <wwwhsd@gmail.com>:
>
> Try this:
>
> replicate <- vector("numeric", len=length(x))
> replicate[order(x)] <- unlist(sapply(rle(sort(x))$lengths, seq_len))
>
> On 19/12/2007, Eric Lecoutre <ericlecoutre@gmail.com> wrote:
> > Dear R-help,
> >
> > I am trying to have a generic way to assess the replicates in a
> character
> > vector.
> > Say that I have the following vector:
> >
> > x <- c('A','B','A','C','C','B')
> >
> > I would like to obtain:
> >
> > replicates <- c(1,1,2,1,2,2)
> >
> > each number beeing the time we see the corresponding value in x.
> >
> > Any clever and generic way to obtain that?
> >
> > Eric
> >
> >
> >
> >
> > --
> > Eric Lecoutre
> > Consultant - Business & Decision
> > Business Intelligence & Customer Intelligence
> >
> >        [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@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.
> >
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>



-- 
Eric Lecoutre
Consultant - Business & Decision
Business Intelligence & Customer Intelligence

	[[alternative HTML version deleted]]

