I have three columns of x, y, and z coordinates in a dataframe in R that I would like to concatenate into one xyz value, like below. I have tried 'paste' with 'collapse'="" and sep="" but am having trouble, I think it's something to do with text vs. numeric variables.
I have:
x y z
1 2 3
2 3 2
3 1 4
4 2 1
I want:
x y z xyz
1 2 3 123
2 3 2 232
3 1 4 314
4 2 1 421
There has to be some extremely easy/simple way to do this in R but I have been Googling and looking through Stack Overflow off-and-on for the past couple days and nothing has come to my attention. All I need is the xyz column to be unique so I can run fixed-effects regressions, (x ranges from 1:4, y from 1:4 and z 1:10) so I have 160 possible combinations. Currently I am using different exponents on the x, y, and z values and then multiplying them to get unique values--surely there's a better way! Thanks