0

I am trying to join several rows that have the same name in the first column but different values in the following columns. Eg:

df
      name x       y       z
    1 sp1  2       4       2
    2 sp2  ca.4    ca.8    ca.4
    3 sp3  1       2       1
    4 sp3  1       2       1
    5 sp4  3       6       3
    6 sp2  5       10      5
    7 sp3  5       10      5

I have been trying this function with no resuts...

as.data.frame(paste(unlist((df), collapse =", ")))

I want them to join by name, such as this:

  name x       y          z
1 sp1  2       4          2
2 sp2  ca.4,5  ca.8,10    ca.4,5
3 sp3  1,1,5   2,2,10     1,1,5
4 sp4  3       6          3  

Thank you in advance.

0 Answers0