Hi Idris,

I do not know what the correct use of ddply would be, but here is another
option using paste() and table();

data.frame(with(df, table(paste("(", x, ",", y, ")", sep = ""))))

HTH,
Jorge


On Tue, Jun 21, 2011 at 2:30 PM, Idris Raja <> wrote:

> I have a dataframe df with two columns x and y. I want to count the number
> of times a unique x, y combination occurs.
>
> For example
>
> x<- c(1,2,3,4,5,1,2,3,4)
> y<- c(1,2,3,4,5,1,2,4,1)
>
> df<-as.data.frame(cbind(x, y))
>
> #what is the correct way to use ddply for this example?
> ddply(df, c('x','y', summarize, ??)
>
> #desired output -- format and order doesn't matter
> # (x, y) count
> #--------------------
> # (1, 1) 2
> # (2, 2) 2
> # (3, 3) 1
> # (4, 4) 1
> # (5, 5) 1
> # (2, 3) 1
> # (3, 4) 1
> # (4, 1) 1
>
>        [[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.
>

	[[alternative HTML version deleted]]

