I would like to know how to create a loop to create the same new variable for 7 different dataframes. Currently, my code looks like this:
m1_02 <- m1_02 %>% mutate(hhid = xa*10^5 + hoso)
m2_02 <- m2_02 %>% mutate(hhid = xa*10^5 + hoso)
m3_02 <- m3_02 %>% mutate(hhid = xa*10^5 + hoso)
m3_02a <- m3_02a %>% mutate(hhid = xa*10^5 + hoso)
m6a2_02 <- m6a2_02 %>% mutate(hhid = xa*10^5 + hoso)
m6b1_02 <- m6b1_02 %>% mutate(hhid = xa*10^5 + hoso)
m6b2_02 <- m6b2_02 %>% mutate(hhid = xa*10^5 + hoso)
I was wondering if there was a way I could create a loop that would create the hhid
variable in the respective dataframes without having to use the mutate
function one by one.
Thank you!