Hi there,
Happy to help if you can make a reprex (FAQ: How to do a minimal reproducible example ( reprex ) for beginners) . Go ahead and make a smaller version of the two matrices as well as the solution will probably be able to generalise for your specific requirement.