Dear R-helpers,

I have a data frame with 3 variables, each record is a unique combination of
the three variables. I would like to count the number of unique values of v3
in each v1, and save it as a new variable v4 in the same data frame.
e.g.
df1
     [v1] [v2] [v3]
[1,] "a"  "C"  "1"
[2,] "b"  "C"  "2"
[3,] "c"  "B"  "3"
[4,] "a"  "B"  "3"
[5,] "b"  "A"  "2"
[6,] "c"  "A"  "1"

In this case, the 4th column would become (2, 1, 2, 2, 1, 2).

Could someone tell me how to do this?

regards,
Lijiang


--

	[[alternative HTML version deleted]]

