Search code examples
rapache-sparksparkr

Concat Multiple Columns into new column Spark R data frame with a Seperator


Used two syntaxes none of them worked.

1)

df_final$concat <- paste(df_final$A,df_final$B,df_final$C,sep="/")

Error - no method for coercing this S4 class to a vector

2)

df_final$concat <- (df_final$A + "/" + df_final$B)

Error - This returned nulls. Any help would be appreciated. All of the columns contain strings.


Solution

  • You can use the following syntax.

    df_final$concat <- concat_ws(df_final$A,df_final$B,df_final$C,sep="/")