r - Unique value combinations with summary count -
say have following data
x <- (c(1,2,1,1,1,2,2,1,2,1,2)) y <- (c(3,4,4,4,4,3,3,4,4,3,3)) table <- data.frame(x,y)
how 1 calculate frequencies of unique combinations, ie 1-4
i have looked summary((table$x)[1] & (table$y)[2])
does involve using the unique
, length
commands? or must use plyr
package , use ddply
thanks in advance !
as ananda suggets function table
way go:
> df <- data.frame(x, y) > table(df) y x 3 4 1 2 4 2 3 2 > table(with(df, paste(x, y, sep="-"))) 1-3 1-4 2-3 2-4 2 4 3 2
Comments
Post a Comment