Convert areas and models into indices and assign sales into those locations of a matrix of zeros.
ij=. area,.model (ij +//. sales) (<"1 ~.ij)}(m,n)$0 If there can be at most one figure for each pair of (area,model) then you can skip the cumulation and the nub: sales (<"1 area,.model)}(m,n)$0 ----- Original Message ----- From: June Kim <[EMAIL PROTECTED]> Date: Saturday, May 17, 2008 7:44 Subject: [Jprogramming] 2-dimensional summary report To: Programming forum <[email protected]> > Suppose the data is given as following: > > data=: 0 : 0 > area model sales > north T2 3 > south T2 4 > north T3 10 > north T3 5 > east T1 1 > west T3 1 > south T2 11 > north T4 2 > west T3 1 > east T4 1 > west T4 6 > ) > d=: (<a:;<2) ((".&.>)@{)`[`]} }. cut;._2 data > > > What I want is a report of sales for area by model: > > > NB. T2 T3 T1 T4 > NB. north 3 > 15 0 2 > NB. south 15 > 0 0 0 > NB. east > 0 0 1 1 > NB. west > 0 2 0 6 > > > The final matrix doesn't need to contain row, column-headers -- > it is > fine that it contains only the sales total for each area and model > pairs. > > I'd like to know easy and simple ways to getting that matrix in J. > What's your suggestion? ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
