3

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().

smz
  • 263
  • 4
  • 11

1 Answers1

10

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
Ista
  • 10,139
  • 2
  • 37
  • 38