(b +/ .* a) % +/a Best if b is a vector.
On Tue, Sep 25, 2012 at 8:15 AM, pascha <[email protected]> wrote: > > I spent a lot of time on this but I can't figure out how to do that: > I have: > "a" (6 x 4): > 1 0 0 1 > 1 1 0 1 > 1 1 0 1 > 1 1 0 1 > 0 1 1 1 > 0 0 0 0 > > and "b" (1 x 6) like: > 1 2 1 3 4 6 > > I'd like to get the average of those in "b" w.r.t column values in "a" > which > are equal to 1. > At the end I'd get the averages (4 x 1 or 1 x 4), like: > (1 + 2 + 1 + 3) % 4 > (2 + 1 + 3 + 4) % 4 > (4) > (1 + 2 + 1 + 3 + 4) % 5 > > could you shed some light on this? > -- > View this message in context: > http://old.nabble.com/array-operation-and-take-average-tp34477891s24193p34477891.html > Sent from the J Programming mailing list archive at Nabble.com. > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
