R change in loop