When running the fragmentation function, everything works fine if wear is a vector with all wear values equal to 1. As soon as there is at least one zero I get the error: Error in object[-omit, , drop = FALSE] : incorrect number of dimensions