Model | Option | A | B | 1 | 2 | 3 | 4 |

FALSE | TRUE | FALSE | TRUE | FALSE | FALSE | ||

TRUE | TRUE | TRUE | FALSE | FALSE | TRUE | ||

TRUE | FALSE | FALSE | FALSE | TRUE | FALSE | ||

FALSE | TRUE | TRUE | TRUE | FALSE | TRUE |

<tbody>

</tbody>

Need to comma delimit groupings of Models and Options based on True False condition. So, what I want:

Model | Option | A | B | 1 | 2 | 3 | 4 |

B | 2 | FALSE | TRUE | FALSE | TRUE | FALSE | FALSE |

A,B | 1,4 | TRUE | TRUE | TRUE | FALSE | FALSE | TRUE |

A | 3 | TRUE | FALSE | FALSE | FALSE | TRUE | FALSE |

B | 1,2,4 | FALSE | TRUE | TRUE | TRUE | FALSE | TRUE |

<tbody>

</tbody>

I hope this is clear enough. Any help would be greatly appreciated. And thanks in advance.