[R] stupid thing with the correlation
Duncan Murdoch
murdoch.duncan at gmail.com
Fri Jan 30 12:44:46 CET 2015
On 30/01/2015 5:22 AM, n omranian via R-help wrote:
> Hi All,
> I'm getting actually nuts. I don't understand the following lines in R:
> Here is the data, all rows are exactly the same!
>> ord_data[pid,]
> c0m2 c0m4 c0m8 c0m16 c0m24 c0m48 c0p2 c0p4 c0p8 c0p16 c0p24 c0p48 c24m2 c24m4 c24m8 c24m16
> 13336382 5.632195 6.442133 5.818143 5.7683 5.862075 6.533181 5.807341 6.709774 5.664199 5.54022 5.385181 6.531977 5.29061 5.776121 6.136176 6.34699
> 13465320 5.632195 6.442133 5.818143 5.7683 5.862075 6.533181 5.807341 6.709774 5.664199 5.54022 5.385181 6.531977 5.29061 5.776121 6.136176 6.34699
> 13467455 5.632195 6.442133 5.818143 5.7683 5.862075 6.533181 5.807341 6.709774 5.664199 5.54022 5.385181 6.531977 5.29061 5.776121 6.136176 6.34699
> 13518680 5.632195 6.442133 5.818143 5.7683 5.862075 6.533181 5.807341 6.709774 5.664199 5.54022 5.385181 6.531977 5.29061 5.776121 6.136176 6.34699
> c24m24 c24m48 c24p2 c24p4 c24p8 c24p16 c24p24 c24p48
> 13336382 5.489161 6.043948 5.807802 5.761756 5.833559 5.293438 5.92068 5.759683
> 13465320 5.489161 6.043948 5.807802 5.761756 5.833559 5.293438 5.92068 5.759683
> 13467455 5.489161 6.043948 5.807802 5.761756 5.833559 5.293438 5.92068 5.759683
> 13518680 5.489161 6.043948 5.807802 5.761756 5.833559 5.293438 5.92068 5.759683
>
> Now I found correlation:
>> pcor <- cor(t((ord_data[pid,])))
>> pcor
> 13336382 13465320 13467455 13518680
> 13336382 1 1 1 1
> 13465320 1 1 1 1
> 13467455 1 1 1 1
> 13518680 1 1 1 1
> But, then I get this funny result !!!
> all(pcor[,1]==1)
> [1] FALSE
>> pcor[2,2]==1
> [1] TRUE
>> pcor[3,2]==1
> [1] FALSE
> Could anybody please comment on this?Many thanks.
> [[alternative HTML version deleted]]
Please just send your messages to r-help, not all those other addresses,
and please don't reply to an existing thread.
Your answer is given in FAQ 7.31.
Duncan Murdoch
More information about the R-help
mailing list