问题
I am looking for a function to concatenate two strings inside SQLDF in R, that works like paste(), but could not find any. The reason for doing that is I want to concatenate two columns while joining two data frames. Instead of using merge() to do the join then use paste(), I sometimes want to use sqldf().
回答1:
Just use the syntax for concatenation in SQL, e.g.,
d <- data.frame(x = c("a", "b"), y = c("1", "2"))
sqldf("select *, x||y from d")
# x y x||y
# 1 a 1 a1
# 2 b 2 b2
来源:https://stackoverflow.com/questions/27995009/how-can-i-concatenate-strings-in-sqldf-in-r