raoul schorer wrote:
> 
> 
> NB. Column index of data y by name x
> colIdxByName =: 4 : 'I. (0 { y) = <x'
> 
> NB. Select a column in data y by index x
> colByIdx =: 4 : '}.x{|:y'
> 
> But if I try:
> 
> colByName =: 4 : 0
>      idx =. x colIdxByName y
>      res =. idx colByIdx y
> )

Your approach is very sound but has some hideous inside detail wrong.
You just need some advice how to debug things at this point.

> 'Valeur' colByName data   NB. nothing happens...

Every expression either yields a very visible error message or returns
*something*.  Have a look at at its shape:

    $ 'Valeur' colByName data

You'll find that you got a matrix with 0 rows but some columns here.

> idx =: 'Valeur' colIdxByName data
> idx colByIdx data       NB. this doesn't work
> 
> 2 colByIdx data  NB. but this does...

Then there must be some difference between idx and 2 even though
not immediately obvious.  Again,

    $ idx

will tell you that you have not your expected scalar 2 here but a
singleton vector.

You'll be certainly able to further track the down, where in your
colByName utility this singleton-instead-of-scalar originates.
Then you can fix that.

                                                Martin

Some extra remarks:

        - idx -: 2
        - datatype idx    NB. when strings disguise as numbers
        - most J'ers would have build colIdxByName upon i. instead of I.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to