In a loop, I define strings based on a test. I iteratively remove these rows from the original matrix (inM) using my index (idx):
inM <- inM[-idx,]
Sometimes idx is empty, i.e. not a single line satisfies the test, therefore idx is of type integer (0). Removing idx from inM then gives an empty matrix, and not the same matrix. As a result, I got an empty matrix for the next iteration ...
Is there a one line solution to avoid this?
source share