In the Wolfram Language Documentation for JoinAcross, there is an example that uses a KeyCollisionFunction to change the keys (labels) that result from a join across operation:
in[]: JoinAcross[{<|a -> 1, b -> X|>}, {<|a -> 1, b -> Y|>},
Key[a], "Inner", KeyCollisionFunction -> Function[x, {left[x], right[x]}]]
This produces:
out[]: {<|a -> 1, left[b] -> X, right[b] -> Y|>}
I have a similar problem, but I would like to Join two arrays (or associations) on Key A, and combine the values associated with Key B. That is...
in[]: JoinAcross[{<|a -> 1, b -> X|>}, {<|a -> 1, b -> Y|>},
Key[a], "Inner", KeyCollisionFunction -> SOME FUNCTION ]
To produce:
{<|a -> 1, b -> {X, Y}|>}
Note, instead of modifying the keys left[b] and right[b], we keep the original key b and combined the values from left and right, into a list associated with the original key b ->{X, Y}. It seems like there should be a straightforward way to do this, but I am not very handy with the syntax for pure functions. Can anyone explain how to do this?