I'm having a problem dynamically concatenating Columns. I'm building a Regional Calculator which sums measures but want it to be flexible enough to accommodate various inputs.
Using mtcars and an example:
ColA <- "mpg"
ColB <- "cyl"
ColC <- "disp"
mtcars$lookup <-paste0(mtcars[[ColA]],mtcars[[ColB]],mtcars[[ColC]])
(I know the above example concatenates Numbers which doesn't make sense! - in my version columns containing strings are used)
This would give me the lookup column that I need. However what I'd like to do is populate my lookup column dynamically. Sometimes there will be 2 columns, sometimes they may be 5 columns and the Column Names will change from one project to the next.
I'm thinking I could populate the strings in ColA > ColX using a List and a For Loop. But I'm not sure how to dynamically solve the lookup creation using paste0....
mtcars$lookup <-paste0(mtcars[[ColA]],......mtcars[[ColX]])
Any ideas how to solve this problem? Thanks!