Chris,
I'm probably not being clear about what I'm trying to do (then again
maybe I'm just not getting what you're trying to tell me!). I was only
using 2 arguments for catalog because the left argument of melt is
supposed to describe how many "static" columns there are. Maybe a more
"realistic" test array will help. In the array below the first two
columns are set i.e. treatment doesn't vary within Tag (129 had the high
treatment and only the high treatment). In another dataset there might
be three static columns say Tag, Gender, Trt.
   tst2
+---+----+-------+-------+-------+-------+
|Tag|Trt |Wgt1   |Wgt2   |Wgt3   |Height |
+---+----+-------+-------+-------+-------+
|129|high|5.15114|5.8615 |8.51623|16.3878|
+---+----+-------+-------+-------+-------+
|125|low |5.51031|6.92476|9.12955|15.6384|
+---+----+-------+-------+-------+-------+
|109|high|3.10655|4.51398|8.51873|14.7903|
+---+----+-------+-------+-------+-------+
|100|high|3.25242|5.14918|8.44444|15.5832|
+---+----+-------+-------+-------+-------+
|108|low |3.89146|5.94608|7.79733|13.1512|
+---+----+-------+-------+-------+-------+ 

What I want is
+---+----+---------+-------+
|Tag|Trt |Variable |Value  |
+---+----+---------+-------+
|129|high|Wgt1     |5.15114|
+---+----+---------+-------+
|129|high|Wgt2     |5.8615 |
+---+----+---------+-------+
...
+---+----+---------+-------+
|108|low |Wgt3     |7.79733|
+---+----+---------+-------+
|108|low |Height   |13.1512|
+---+----+---------+-------+

I also tried the last line of melt as
   lbls,(>,{(<"1 a);<<"0 b),.,c
Which gave the same level of boxing for the first and 2nd arguments but
the question is still how to remove it.  


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chris Burke
Sent: Thursday, 8 February 2007 19:02
To: Programming forum
Subject: Re: [Jprogramming] reshaping array

Sherlock, Ric wrote:
> I've tried to define a verb melt that generalises the technique for an

> arbitrary number of ID columns. It seems to work except that I have an

> extra level of boxing around the ID columns. How best to remove them? 
> (I figure once that's solved then the labels will match at the top OK 
> too!)

You can use { (catalog) with a list of arguments to build the labels,
e.g.

   >,{(100+i.2);(5*i.3);21+i.4
100  0 21
100  0 22
100  0 23
100  0 24
100  5 21
100  5 22
100  5 23
100  5 24
100 10 21

Your problem is that you only use catalog with two arguments, and each
item of the first is boxed, while each item of the second is open.

Also, it just seems easier to separate the labels from the data, i.e.
write a verb of the form:

   meltdown=: 4 : '(>,{x),.,y'

   ((100+i.2);22+i.3) meltdown i.2 3
100 22 0
100 23 1
100 24 2
101 22 3
101 23 4
101 24 5

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to