'Combine cells in the first row

can somebody help me?

This is my actual data_frame

This is my actual data_frame

and this is what I'd want to get

and this is what I'd want to get

Is there a way to combine only the cells in the first row in R?

I was trying to do it in excel one by one but I've more than 6000 columns so it takes me ages!

Thank you for your help!



Solution 1:[1]

You could collapse all the cells in the fist row into one cell and leave the others empty. If x is your data frame:

x[1,] <- c(paste(x[1,], collapse=""), rep("", ncol(x)-1))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dbogdan