Hadley and Dennis:

THANK YOU THANK YOU! This is exactly what I was looking for.

Ryan


On Wed, Jan 26, 2011 at 5:27 AM, Dennis Murphy <djmuser@gmail.com> wrote:
> > Hi:
> >
> > Here are two more candidates, using the plyr and data.table packages:
> >
> > library(plyr)
> > ddply(X, .(x, y), function(d) length(unique(d$z)))
> >  x y V1
> > 1 1 1  2
> > 2 1 2  2
> > 3 2 3  2
> > 4 2 4  2
> > 5 3 5  2
> > 6 3 6  2
> >
> > The function counts the number of unique z values in each sub-data frame
> > with the same x and y values. The argument d in the anonymous function is
> a
> > data frame object.
>
> Another approach is to use the much faster count function:
>
> count(unique(X))
>
> Hadley
>
> --
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> http://had.co.nz/
>



-- 
Ryan Utz
Postdoctoral research scholar
University of California, Santa Barbara
(724) 272 7769

	[[alternative HTML version deleted]]

