Given three arrays, for example
s={1,3,2,3,1,2,3,2,1}
r={4,2,6,5,4,6,2,1,3}
f={1,3,9,1,8,4,4,8,2}
I'm trying to output four summary arrays
- The uniques of s
- For each unique of s, the maximum of r with that s
- The number of entries which have that (s,r) combination
- The sum of f's of those corresponding entries
For example
o1={1,2,3}
o2={4,6,5}
o3={2,2,1}
o4={9,13,1}
(For s=1 the maximum r values was 4, of which there were two of them, and the sum of the corresponding f values is 1+8=9)
I've been doing a loop across the uniques using Position function, etc. Slow and not optimized using the Mathematica notation. The arrays can be millions in length.
Thank you for your help.