using argument passed to function for left join

For left_join to work

df2 <- df1 %>% left_join(code_label_temp, by = c(statcat='code'))

It's not clear what the aim is, so I can't suggest how to join. See the FAQ: How to do a minimal reproducible example reprex for beginners.