R change of loop