First question from me, hope it’s phrased correctly. I couldn’t find anything on this so I’ll bite the bullet.
I’d like to create a geom_tile plot in which for each combination of x and y, I have 5 variables for the z that all sum to one. I’d like the colour of the square for each x-y combination to reflect which z number is largest. For example, imagine I have 5 z variables a, b, c, d and e. If a=1 and b=c=d=e=0, the square would be blue, if b=1 and a=c=d=e=0 it would be red, etc. If a=b=0.5 and the others are zero, it would be an interpolated colour (i.e. purple). Perhaps even better, a crosshatch of red and blue, but I don’t know if that is possible in ggplot.
I am not sure how best to go ahead. I thought about plotting 5 geom_tile plots on top of each other, where each one is a different colour and the alpha is scaled by e.g. the value of a (so the cell is transparent when a = 0 and strongly coloured when a = 1). There might also be a way to do it using colour ramps, but I drew a blank there too.
If anyone can see how to do this off the top of their head, I’d be much obliged. Here’s a dataset of random numbers in the same format as my actual data.
rand <- matrix(runif(50*50*5), ncol=5, nrow=50*50)
rand <- rand / apply(rand, 1, sum) # Make sure the numbers sum to one in each row
d <- data.frame(a = rand[,1],
b = rand[,2],
c = rand[,3],
d = rand[,4],
e = rand[,5],
expand.grid(x = 1:50, y = 1:50))
Update: By using the first answer from sebastian-c and my own dataset, I was able to make this figure. I obtained the colours using the function brewer.pal(5,”Spectral”) in the package RColorBrewer. Needs a custom legend, but otherwise I am pretty happy with it. The solid colours show pure “Evolutionarily stable strategies” (ESS; i.e. strategies that cannot be beaten by a mutant strategy). Areas of overlapping colours show mixed ESS, in which the equilibrium is a stable balance of two or more strategies.

I took the liberty of simplifying your example a bit down to 3 columns. Honestly, I don’t think this works well with any more than 2, but here’s how I’ve gone about it. I’ve also abused alpha channels so if you lay down the tiles in a different order, the colours change. This should hopefully work as a starting point for someone else. First, we’ll generate data:
Now for the plot:
I was thinking about, for 3 columns, using amounts of red, green and blue, but this doesn’t work for anything greater than 3 columns.
EDIT: A specific solution for up to 3 columns (I mixed the blue and green up):
You could do this with 2 colours if you set one of red, green or blue to 0.