Мы можем использовать base R
без зацикливания
cols <- c("DAT3", "DAT4")
df3 <- df1
df3[cols] <-matrix(paste(as.matrix(df1[-1]), as.matrix(df2[-1])), nrow = nrow(df1))
df3
# DAT1 DAT3 DAT4
#1 1 this is a comment this is a comment
#2 2 this is a comment this is a comment
#3 3 this is a comment this is a comment
данные
df1 <- structure(list(DAT1 = 1:3, DAT3 = c("this is", "this is", "this is"
), DAT4 = c("this is", "this is", "this is")), class = "data.frame",
row.names = c(NA,
-3L))
df2 <- structure(list(DAT1 = 1:3, DAT3 = c("a comment", "a comment",
"a comment"), DAT4 = c("a comment", "a comment", "a comment")),
class = "data.frame", row.names = c(NA,
-3L))