I have a 2-column data frame of the x- and y-coordinates of the points. I want to create a table from the number of occurrences of each point. Using the command table(), a table is created for all possible xy pairs. I can exclude additional functions with
fullTable <- table(coords)
smalLTable <- subset(fullTable, fullTable > 0)
And then I'm sure I can do something with dimnames(fullTable)to get the appropriate coordinates, but is there a better way? Is something built? Something with
coords <- data.frame(x = c(1, 1, 2, 2, 3, 3), y = c(1, 1, 2, 1, 1, 1))
will return
x y count
1 1 2
2 1 1
2 2 1
3 1 2
source
share