I have a large set of data in which I need to compare several samples in different tests and under varying conditions. I am looking for a way to pair and analyze these easily. As an example, lets say I have Samples (S) a, b, and c, which undergo tests (T) 1 and 2, under conditions (C) x, y and z, which output results (R) R1 and R2.

`S T C R1 R2 a 1 x 2.9 a 1 y 2.6 a 1 z 8.7 a 2 x 9.4 0.372 a 2 y 8.1 0.208 a 2 z 7.6 0.154 b 1 x 7.5 b 1 y 7.3 b 1 z 1.7 b 2 x 3.9 0.213 b 2 y 7.9 0.435 b 2 z 2.5 0.294 c 1 x 6.2 c 1 y 1.8 c 1 z 6.3 c 2 x 1.5 0.246 c 2 y 6.0 0.496 c 2 z 1.7 0.167 `

The tests have different outputs, and I need to apply specific functions depending on the test. Such as:

`Test1[a,b] = R1a/R1b Test2[a,b] = R1a/R2a - R1b/R2b `

The tests should only be applied to samples with matching conditions, but each sample should be paired. So a result would be:

`S1 S2 T C R a b 1 x 2.9/7.5 a c 1 x 2.9/6.2 a b 2 x 9.4/0.372-3.9/0.213 a c 2 x 9.4/0.372-1.5/0.246 a b 1 y 2.6/7.3 ... `

I’ve been trying to get this right for a while and just end up confusing myself. Anyone have a solution or suggestions? If you want an easily copyable format of the example:

{{S,T,C,R1,R2},{a,1,x,2.9},{a,1,y,2.6},{a,1,z,8.7},{a,2,x,9.4,0.372},{a,2,y,8.1,0.208},{a,2,z,7.6,0.154},{b,1,x,7.5},{b,1,y,7.3},{b,1,z,1.7},{b,2,x,3.9,0.213},{b,2,y,7.9,0.435},{b,2,z,2.5,0.294},{c,1,x,6.2},{c,1,y,1.8},{c,1,z,6.3},{c,2,x,1.5,0.246},{c,2,y,6.,0.496},{c,2,z,1.7,0.167}}