How can I concatenate strings in SQLDF in R

此生再无相见时 提交于 2021-01-28 01:15:37

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!