In <mydata> each box contains a 1 element vector...
$each mydata
+-+-+-+-+-+-+-+-+-+-+
|1|1|1|1|1|1|1|1|1|1|
+-+-+-+-+-+-+-+-+-+-+
In <lin> each box contains a scalar (atom with no shape)
$each lin
+++++++++++
|||||||||||
+++++++++++
When you test each variable against the test item of <'1',
the shape doesn't match in mydata, but does in lin:
mydata = <'1'
0 0 0 0 0 0 0 0 0 0
lin = <'1'
0 1 0 0 0 0 0 0 0 0
Likewise if you test against a test item of <,'1' vice versa:
mydata = <,'1'
0 1 0 0 0 0 0 0 0 0
lin = <,'1'
0 0 0 0 0 0 0 0 0 0
You can also apply the verb '=' within each box, so try this ...
]mydata1 =: 'test1';(2 3$'1234');'not 1 to test'
+-----+---+-------------+
|test1|123|not 1 to test|
| |412| |
+-----+---+-------------+
'1' =&.> mydata1 NB. This tests for '1' inside each box ...
+---------+-----+-------------------------+
|0 0 0 0 1|1 0 0|0 0 0 0 1 0 0 0 0 0 0 0 0|
| |0 1 0| |
+---------+-----+-------------------------+
Note =&.> can use the cover name 'each' (for &.>) as follows:
'1' = each mydata1
+---------+-----+-------------------------+
|0 0 0 0 1|1 0 0|0 0 0 0 1 0 0 0 0 0 0 0 0|
| |0 1 0| |
+---------+-----+-------------------------+
When you use {. you need to apply it within each box:
({. each mydata)=<'1'
0 1 0 0 0 0 0 0 0 0'
Hope this helps.../Rob Hodgkinson
On 27/02/08 4:21 PM, "The World" <[EMAIL PROTECTED]> wrote:
> I've been playing with the readcvs function and am having a problem with
> the boxed data. I can read in a 2 dimensional array of boxed character
> data. I can select any particular column using
>
> col =. idx {"_1 myboxeddata
>
> The problem comes in when I want to test each of the boxes in the column
> to see which one is equal to the single number 1 (as a character of
> course). I would like to generate an array of 1s and 0s, the 1s being
> where the number 1 character is. I would like to do this in the
> following fashion
>
> col = <'1'
>
> But I always get 0s as the answer even though the boxed list contains a
> single boxed 1 character
>
> I've recreated the problem in simpler form:
>
> mydata =. |: ;: 1 ]\'0123456789'
> mydata
> │0│1│2│3│4│5│6│7│8│9│
>
> mydata = <'1'
> 0 0 0 0 0 0 0 0 0 0
>
> $mydata
> 1 10
>
> So because this horizontal format of mydata was transposed from a column
> the shape is a little different than if I built this directly using ;
>
> lin =. '0';'1';'2';'3';'4';'5';'6';'7';'8';'9'
> lin
> │0│1│2│3│4│5│6│7│8│9│
> $lin
> 10
> lin = <'1'
> 0 1 0 0 0 0 0 0 0 0
>
> which works the way I suspect. Even if I use take ({.) to get the
> dimensions of the boxed list mydata the same as lin in the previous
> example I still get all 0s:
>
> {. mydata
> │0│1│2│3│4│5│6│7│8│9│
> ${. mydata
> 10
> ({. mydata) = <'1'
> 0 0 0 0 0 0 0 0 0 0
>
> So what is going on here that I am missing?
>
>
>
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm