Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I'm sorry I don't understand what are you trying to say with: "I can simply take the unique list of products between the 3 and then fill the space in the stores with the products where the products are ranked based on £/space"
that could be, in fact I made some confusion and at first I wrote the code with products on the rows and stores on the columns, but I fixed it before you posted this comment and it should work, grouping stores. dist(dt) takes rows to be the units to create distance between of.