I am trying to replicate some analysis I had done using STATA in R but I need your help. Is there a way I can use a for loop to create new variables whose values comprise adjustments of already existing variables? I was converting income from Uganda shillings to USD but the rates varied at baseline, midline and endline periods. I used “mutate” and “case_when” for each variable but found the code to be lengthy and thought a loop, which I used in STATA, would make my work easier. I have attached screenshots of the STATA code and R code for your reference.