What I want to do is check a data frame of ordered pairs of x and y values (in this particular set there are only 4 possible values) and count how many times each particular value happens.
For example, my data frame has columns 1 and 2 as follows:
data <- data.frame(col1=c(-.25, 0, -.25, -.77, 0, 0, 0, -2.5),
col2=c(0.9, 0, 0.9, 2.9, 0, 0, 0, 0.9))
And I would like to count the times each possible pair arises. The closest thing I have found is table()
which returns 16 possible values, which is not what I need. I.E, I try
test=as.data.frame(table(data[,1:2]))
which feeds in the two columns into a table as test. What I get back is a matrix enumerating 9 'possible' combinations - I guess what it does is simply cross-reference each column value and count the number of times it arises.
Edit: I realize that the non-zero entries in the third column of the table are the ones I want, but I eventually need this to perform things with 24 total sets, so it should be automated as possible.