Can you confirm if the next break cancels the inner for loop? for (out in 1:n_old){ id_velho
stackoverflow.com