How To Convert Full Data Matrix To Linearised Left Data Matrix?
1
2
Entering edit mode
13.0 years ago
User 0422 ▴ 150

Hi all,

Is there a way to convert full data matrix to linearised left data matrix?

e.g full data matrix

    Bh1    Bh2    Bh3    Bh4    Bh5    Bh6    Bh7
Bh1    0    0.241058    0.236129    0.244397    0.237479    0.240767    0.245245
Bh2    0.241058    0    0.240594    0.241931    0.241975    0.236266    0.239739
Bh3    0.236129    0.240594    0    0.24126    0.240514    0.237112    0.246041
Bh4    0.244397    0.241931    0.24126    0    0.245298    0.243085    0.248259
Bh5    0.237479    0.241975    0.240514    0.245298    0    0.241861    0.244328
Bh6    0.240767    0.236266    0.237112    0.243085    0.241861    0    0.241861
Bh7    0.245245    0.239739    0.246041    0.248259    0.244328    0.241861    0

linearized left data matrix

    Bh1    Bh2    Bh3    Bh4    Bh5    Bh6    Bh7
Bh1    0                        
Bh2    0.241058    0                    
Bh3    0.236129    0.240594    0                
Bh4    0.244397    0.241931    0.24126    0            
Bh5    0.237479    0.241975    0.240514    0.245298    0        
Bh6    0.240767    0.236266    0.237112    0.243085    0.241861    0    
Bh7    0.245245    0.239739    0.246041    0.248259    0.244328    0.241861    0

thanks

• 1.7k views
ADD COMMENT
3
Entering edit mode
13.0 years ago

using awk:

awk -F '[\t ]+' '/^Bh*/ {for(i=1;i<= n+2;i++) {printf("%s ",$i);} printf("\n"); n++; next;} { printf("%s\n",$0); next;} ' yourfile.txt

    Bh1 Bh2 Bh3 Bh4 Bh5 Bh6 Bh7
Bh1 0 
Bh2 0.241058 0 
Bh3 0.236129 0.240594 0 
Bh4 0.244397 0.241931 0.24126 0 
Bh5 0.237479 0.241975 0.240514 0.245298 0 
Bh6 0.240767 0.236266 0.237112 0.243085 0.241861 0 
Bh7 0.245245 0.239739 0.246041 0.248259 0.244328 0.241861 0
ADD COMMENT
0
Entering edit mode

many thanks! working perfectly.

ADD REPLY

Login before adding your answer.

Traffic: 2226 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6