Skip to content
Prev 388414 / 398502 Next

concatenating columns in data.frame

You can do the same steps but without so much intermediate saving to
shorten it

f <- function(x) {
  do.call(rbind,lapply(1:nrow(x),
                       function(r) {paste(x[r,], collapse="_")}))
}

df_combo <- cbind(df,Combo=f(df[,c(4,2)]))

HTH,
Eric
On Thu, Jul 1, 2021 at 5:37 PM Micha Silver <tsvibar at gmail.com> wrote: