I like the cor()
function but would like to know how to get a count of the number of pairs in a sparse matrix giving rise to the correlation values.
Many thanks.
Here's a very simplified version of the kind of data table I have. example data table picture
I've also added a cut down version of the actual file I'm working on here
What I'd like is to find a way to give me something like the following matrix (below is from the pic rather than the file in the hyperlink): example desired output
This shows how many pairs of values there are in common between columnA and columnB so I can see which columns are worth comparing in a correlation. Does that make sense?
dput(mat) structure(list(A = c(9.4, 9.4, 4.7, 1.2, NA, 0.6, 7.712, 0.2, NA, NA, 3.13, NA, 1.56, 6.25, NA, NA, 0.9471, NA, 1.56, 1.2, 0.78, NA, NA, NA, NA, NA, NA), B = c(4.7, 12.5, 2.3, 2.3, 9.4, 0.78, 9.45, 0.6, NA, NA, 3.13, NA, 2.3, 6.25, NA, NA, 10.72, NA, 2.3, 12.5, 6.25, NA, NA, NA, NA, NA, NA), C = c(4.7, 9.4, 4.7, 0.6, NA, 0.6, 10.84, 0.2, 3.67, 2.345, 3.13, 3.288, 1.56, 9.4, 11.21, 0.6, 2.256, 50, 1.56, 3.13, 0.78, 18.7, 0.66, 1.2, 6.26, 6.258, 50)), .Names = c("A", "B", "C"), class = "data.frame", row.names = c(NA, -27L))