Error in galax_samples_mx2[, 6] : subscript out of bounds

With this code you are trying to calculate the mean of the sixth column of galax_samples_mx2 but the error message is telling you that galax_samples_mx2 doesn't have 6 columns.

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.