I have the code below, which I thought would let me merge several data frames together.
codes <- c('agglevel','industry','ownership','size','area')
ann2012full <- ann2012
for(i in 1:length(codes)){
eval(parse(text=paste('ann2012full <- left_join(ann2012full,
',codes[i],')', sep='')))
}
It seems like the first 3 files merge fine, and when I get the 4th file, I get this error message.
Error in left_join_impl(x, y, by$x, by$y, suffix$x, suffix$y, check_na_matches(na_matches)) :
Can't join on 'own_code' x 'own_code' because of incompatible types (integer / character)
I'm guessing there must be a way to coerce the integers into characters, and do the merge, right. I am just not sure how to get this to work. I was hoping for an elegant looping option, rather than doing this 5 separate and distinct ways. Thanks.