[Solved] assign value to a variable rather than using if statement
This is a merge operation as far as I can tell. Make a little lookup table with your Gbcode/ncnty data, and then merge it in. # lookup table lkup <- data.frame(Gbcode=c(11,12,13),ncnty=c(20,19,198)) #example data dt <- data.frame(Gbcode=c(11,13,12,11,13,12,12)) dt # Gbcode #1 11 #2 13 #3 12 #4 11 #5 13 #6 12 #7 12 Merge: merge(dt, … Read more