I am trying to concatenate 2 columns of a data-frame in R using sqldf command. However, it treats them as numeric and sums them up. I looked at the solution to a similar question on stackoverflow but it still doesn't work for me.
Here's what my DF looks like:
SP1 SP2
521 526
521 523
What I want is:
SP
521-526
521-523
I tried the following:
sqldf("select SP1 + '-' + SP2 as SP from DF")
I also tried:
DF2 <- transform(DF, SP1 = as.character(SP1), SP2 = as.character(SP2)))
sqldf("select SP1 + '-' + SP2 as SP from DF2")
In both cases, the result I get is
SP
1047
1044
Any thoughts?