Near perfect correlation yields very low correlation coefficient Can anyone tell me why this near-perfect correlation yields a very low correlation coefficient?
a <- c(1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1)
b <- c(1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1)
cor.test(a,b)

        cor 
-0.06666667

Whereas this near-perfect correlation yields a very high coefficient
a <- c(1,2,3,4,5,6,8,8,9,10,11,12,13,14,15,16)
b <- c(1,2,3,4,5,6,7,8,9,10,11,13,13,14,15,16)
cor.test(a,b)

    cor 
0.99719

I am running a study testing the agreement between two binary variables where, like my first example, there is near-ubiquitous agreement between the two variables (122/128 agree), yet, like my first example, I am getting a very low correlation coefficient and a very high p-value for the test. Is there any solution? Am I going mad? 
 A: A correlation coefficient measures the degree of variation that is shared between two variables, as a fraction of the total variance of both. In your first example, variables $a$ and $b$ are almost perfectly constant. The only variance that occurs is that one of their elements differs from the others, being higher by 1. However, since this occurs at different points in $a$ & $b$, the variance is not shared.  
In other words, for a correlation coefficient to be high, you need it to be such that when $a$ goes up, $b$ goes up, and when $a$ goes down, $b$ goes down. 
You seem to be interested in a different metric, which essentially tells you how close the two variables are to being equal across their paired observations. This is not what a correlation does. In fact, correlation coefficients are not sensitive to the mean or scale of either variable. E.g. in your second example, if you added 1,000 to the values of $b$, you would still get the same correlation out, even though the difference in values between $a$ & $b$ would then be very high. 
