Sorry but your code is not actually reproducible since we don't have access to "matrixbc.txt" file, and it's not pretty clear what you want to achieve, could you elaborate a little more in your question? Also, please narrow down your code to just the relevant section (only include the libraries relevant to your issue).
Maybe this FAQ would give you a better idea of how to make a proper reprex