There's probably a more elegant way, but this works:
ax0=. }.0{"1 tst NB. Drop corner
ax1=. }.0{tst NB. Drop corner
]dat=. ,}.}."1 tst NB. Raveled data
+-+-+-+-+-+-+-+-+-+-+--+--+--+--+--+--+--+--+--+--+
|0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|
+-+-+-+-+-+-+-+-+-+-+--+--+--+--+--+--+--+--+--+--+
('id';'cat';'val'),(ax0#~(#dat)%#ax0),.(ax1$~#dat),.dat
+---+---+---+
|id |cat|val|
+---+---+---+
|100|21 |0 |
+---+---+---+
|100|22 |1 |
+---+---+---+
|100|23 |2 |
+---+---+---+
|100|24 |3 |
+---+---+---+
|100|25 |4 |
+---+---+---+
|101|21 |5 |
...
|103|24 |18 |
+---+---+---+
|103|25 |19 |
+---+---+---+
On 2/7/07, Sherlock, Ric <[EMAIL PROTECTED]> wrote:
Is there a built in mechanism for doing the following common operation?
How would I go about reshaping the following data from this
]tst=.(<'id') (<0;0)}(;/20+i.6),((;/100+i.4),.<"0 i.4 5)
+---+--+--+--+--+--+
|id |21|22|23|24|25|
+---+--+--+--+--+--+
|100|0 |1 |2 |3 |4 |
+---+--+--+--+--+--+
|101|5 |6 |7 |8 |9 |
+---+--+--+--+--+--+
|102|10|11|12|13|14|
+---+--+--+--+--+--+
|103|15|16|17|18|19|
+---+--+--+--+--+--+
To this?
+---+---+---+
|id |cat|val|
+---+---+---+
|100| 21| 0|
+---+---+---+
|100| 22| 1|
+---+---+---+
|100| 23| 2|
+---+---+---+
|100| 24| 3|
+---+---+---+
|100| 25| 4|
+---+---+---+
|101| 21| 5|
+---+---+---+
|101| 22| 6|
...
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
Devon McCormick
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm