Sponsored Content
Top Forums Shell Programming and Scripting two-column data to matrix in AWK Post 302511315 by vgersh99 on Wednesday 6th of April 2011 12:20:46 PM
Old 04-06-2011
Quote:
Originally Posted by Shell_Life
How many different values can you have in column 1 and column 2?
This should not matter.
Code:
nawk '{a[$1,$2]++;r[$1];c[$2]}END {for(ci in c) printf OFS ci;print "";for (ri in r) {printf ri; for (ci in c) {idx=ri SUBSEP ci;printf OFS ((idx in a)?a[idx]:0)}print ""}}' OFS='\t' myFile

This User Gave Thanks to vgersh99 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extract data from a data matrix with filter criteria

Here is what old matrix look like, IDs X1 X2 Y1 Y2 10914061 -0.364613333 -0.362922333 0.001691 -0.450094667 10855062 0.845956333 0.860396667 0.014440333 1.483899333... (7 Replies)
Discussion started by: ssshen
7 Replies

2. Emergency UNIX and Linux Support

AWK - check column data

Hi, I have a data in a file . Infile: 1 e 1.2 1.6 5 f 2.3 3.6 3 g 1.2 2.6 6 i 2.3 3.6 8 o 1.2 3.6 output: 1 e 1.2 1.6 5 f 2.3 3.6 3 g 1.1 2.6 6 i 2.2 3.5 8 o 1.0 3.4 (17 Replies)
Discussion started by: vasanth.vadalur
17 Replies

3. Ubuntu

How to convert full data matrix to linearised left data matrix?

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 ... (8 Replies)
Discussion started by: evoll
8 Replies

4. Shell Programming and Scripting

convert data into matrix- awk

is it possible to count the number of keys based on state and cell and output it as a simple matrix. Ex: cell1-state1 has 2 keys cell3-state1 has 4 keys. Note: Insert 0 if no data available. input key states cell key1 state1 cell1 key1 state2 cell1 key1 ... (21 Replies)
Discussion started by: quincyjones
21 Replies

5. Shell Programming and Scripting

Printing another column using awk and input data

Hi, I have data of the following type, chr1 234 678 39 852 638 abcd 7895 chr1 526 326 33 887 965 kilj 5849 Now, I would like to have something like this chr1 234 678 39 852 638 abcd 7895 <a href="http://unix.com/thread=chr1:234-678">Link</a> chr1 526 326 33 887 965 kilj 5849 <a... (5 Replies)
Discussion started by: jacobs.smith
5 Replies

6. Shell Programming and Scripting

3 column .csv --> correlation matrix; awk, perl?

Greetings, salutations. I have a 3 column csv file with ~13 million rows and I would like to generate a correlation matrix. Interestingly, you all previously provided a solution to the inverse of this problem. Thread title: "awk? adjacency matrix to adjacency list / correlation matrix to list"... (6 Replies)
Discussion started by: R3353
6 Replies

7. Shell Programming and Scripting

column to matrix

Hello All, I need your help in the following problem. I have a matrix of 500 columns and 1000 rows and in each cell, it is having a value range from 0 to 9. I would like to convert each column in to a matrix, according to the value in each cell (ie) 0 to 9. For each column, I need a matrix... (5 Replies)
Discussion started by: Fredrick
5 Replies

8. Shell Programming and Scripting

How order a data matrix using awk?

is it possible to order the following row clusters from ascending to descending. thanx in advance input 1 2 4 0 1 2 4 0 3 3 3 3 1 5 1 0 1 5 1 0 6 0 0 0 5 1 1 1... (4 Replies)
Discussion started by: quincyjones
4 Replies

9. Shell Programming and Scripting

Transpose matrix based on second column using awk

Hi, Is it possible to transpose the matrix like this using awk ? Many thanks in advance Input abc Name_1 0 abc Name_2 1 abc Name_3 2 abc Name_4 0.4 def Name_1 0 def Name_2 9 def Name_3 78 def Name_4 1 Output abc def Name_1 0 ... (4 Replies)
Discussion started by: quincyjones
4 Replies

10. Shell Programming and Scripting

How to get row data printed in column using awk?

Hi team, I have below sample file. $ cat sample dn: MSISDN=400512345677,dc=msisdn,ou=NPSD,serv=CSPS,ou=servCommonData,dc=stc structuralObjectClass: NphData objectClass: NphData objectClass: MSISDN entryDS: 0 nodeId: 35 createTimestamp: 20170216121047Z modifyTimestamp: 20170216121047Z... (3 Replies)
Discussion started by: shanul karim
3 Replies
GLMULTMATRIX(3G)														  GLMULTMATRIX(3G)

NAME
glMultMatrixd, glMultMatrixf - multiply the current matrix with the specified matrix C SPECIFICATION
void glMultMatrixd( const GLdouble *m ) void glMultMatrixf( const GLfloat *m ) PARAMETERS
m Points to 16 consecutive values that are used as the elements of a 4x4 column-major matrix. DESCRIPTION
glMultMatrix multiplies the current matrix with the one specified using m, and replaces the current matrix with the product. The current matrix is determined by the current matrix mode (see glMatrixMode). It is either the projection matrix, modelview matrix, or the texture matrix. EXAMPLES
If the current matrix is C, and the coordinates to be transformed are, v=(v[0],v[1],v[2],v[3]). Then the current transformation is Cxv, or c[0] c[4] c[8] c[12] v[0] (c[1] c[5] c[9] c[13])x(v[1]) c[2] c[6] c[10] c[14] v[2] c[3] c[7] c[11] c[15] v[3] Calling glMultMatrix with an argument of m=m[0],m[1],...,m[15] replaces the current transformation with (CxM)xv, or c[0] c[4] c[8] c[12] m[0] m[4] m[8] m[12] v[0] (c[1] c[5] c[9] c[13])x(m[1] m[5] m[9] m[13])x(v[1]) c[2] c[6] c[10] c[14] m[2] m[6] m[10] m[14] v[2] c[3] c[7] c[11] c[15] m[3] m[7] m[11] m[15] v[3] Where 'x' denotes matrix multiplication, and v is represented as a 4x1 matrix. NOTES
While the elements of the matrix may be specified with single or double precision, the GL may store or operate on these values in less than single precision. In many computer languages 4x4 arrays are represented in row-major order. The transformations just described represent these matrices in column-major order. The order of the multiplication is important. For example, if the current transformation is a rotation, and glMultMatrix is called with a translation matrix, the translation is done directly on the coordinates to be transformed, while the rotation is done on the results of that translation. ERRORS
GL_INVALID_OPERATION is generated if glMultMatrix is executed between the execution of glBegin and the corresponding execution of glEnd. ASSOCIATED GETS
glGet with argument GL_MATRIX_MODE glGet with argument GL_COLOR_MATRIX glGet with argument GL_MODELVIEW_MATRIX glGet with argument GL_PROJECTION_MATRIX glGet with argument GL_TEXTURE_MATRIX SEE ALSO
glLoadIdentity(3G), glLoadMatrix(3G), glMatrixMode(3G), glPushMatrix(3G) GLMULTMATRIX(3G)
All times are GMT -4. The time now is 04:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy