[R] stupid thing with the correlation

2015-01-30 Thread n omranian via R-help
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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] stop a function

2015-01-30 Thread n omranian via R-help
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]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] stupid thing with the correlation

2015-01-30 Thread n omranian via R-help
Well, yes, I do agree with you.
And thanks a lot, I found the FAQ 7.31. very useful. 

Best,N.
 

 On Friday, January 30, 2015 12:44 PM, Duncan Murdoch 
 wrote:
   

 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



   
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.