[Solved] Concatenating two string variables in dataframe in R


It would help if you provided more information. Here is an example:

df <- data.frame(x=1:26, y=as.factor(LETTERS))
paste(df$x, df$y)
[1] "1 A"  "2 B"  "3 C"  "4 D"  "5 E"...
paste(df$x, df$y, sep="")
[1] "1A"  "2B"  "3C"  "4D"  "5E"...

It doesn’t matter what class the elements are, the engine will convert them to character class.

If this does not solve it, include a sample of your data to get more help.

13

solved Concatenating two string variables in dataframe in R