?ave

> a
[1] 2 3 3 4
> cbind(a, ave(a, a, FUN=length))
     a
[1,] 2 1
[2,] 3 2
[3,] 3 2
[4,] 4 1
>


On Sun, Feb 6, 2011 at 8:21 PM, Carrie Li <carrieands...@gmail.com> wrote:
> Hello R-helpers,
>
> I have a question about counting numbers.
> Here is a simple example.
>
> a=c(2, 3, 3,4)
>> table(a)
> a
> 2 3 4
> 1 2 1
>
> so, I can to create another variables that has the corresponding counting
> numbers.
> In this case, I want to have:
>
> b=c(1,2,2,1)
>
> Is there any way coding for this ?
>
> Thanks for helps!
>
> Carrie--
>
>        [[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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

______________________________________________
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.

Reply via email to