You'll want the more general form of indexing, using boxes.

   i.3 4
0 1  2  3
4 5  6  7
8 9 10 11
   (<1 1) { i.3 4
5
   _ (<1 1)} i.3 4
0 1  2  3
4 _  6  7
8 9 10 11

A more complete description of selection is here:
http://www.jsoftware.com/help/jforc/more_verbs_for_boxes.htm#_Toc191734399

Marshall

On Tue, Feb 28, 2012 at 11:49 PM, PackRat <pack...@anet.com> wrote:

> I have a table "b" (example below) which is the transpose of table "a"
> which is read in from a file.  Here's what table b looks like, just so
> you have an idea of what's where:
>
> +--------+-----------+--------+--------+-----------+...
> |F       |CAT        |DE      |CSX     |XOM        |...
> +--------+-----------+--------+--------+-----------+...
> |Ford    |Caterpillar|Deere   |CSX     |Exxon Mobil|...
> +--------+-----------+--------+--------+-----------+...
> |3710    |665        |410     |890     |4000       |...
> +--------+-----------+--------+--------+-----------+...
> |19560307|19291202   |19330609|19801103|19991201   |...
> +--------+-----------+--------+--------+-----------+...
> |0       |0          |0       |0       |0          |...
> +--------+-----------+--------+--------+-----------+...
> |0       |0          |0       |0       |0          |...
> +--------+-----------+--------+--------+-----------+...
>
> The problem I'm having is with amending individual cells in both row 4
> and row 5 (the last two rows) of table b.  (I've run into this problem
> before, but I created lengthy workarounds which are not really J-ish.
> I decided this time to ask the wisdom of the J community to finally
> find out once and for all what the "right" way of doing this kind of
> thing is.)
>
> I don't run into problems READING an individual cell, such as:
>
>   stocksym=. toupper > (j { 0 { b)
>
> However, when I attempt to WRITE an amend into the jth (e.g., first)
> cell of row 4 of table b, for example:
>
>   b=. (< stocknum) j } (4 { b)
>
> table b is incorrectly changed (compared to my intent, that is) from
> the table shown above to a list instead:
>
>   +-+-+-+-+-+...
>   |6|0|0|0|0|...
>   +-+-+-+-+-+...
>
> Is there some "standard" way of making such amends within a table that
> I seem to be missing somewhere along the line?  Thanks for your help!
>
>
> Harvey
>
> ----------------------------------------------------------------------
> 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