How can I make 4 columns into one?

Hello,
I'm a total beginner and I really need help.

How can I make 4 columns into one?

I tried it with paste, but he also copied the NA's here.
Thanks in advance :slight_smile:

What do you want the values in the single column to be? The sum of the four variables, the first non-NA value, or something else?

I am not sure what you want but this may do. I am calling your data set dd

pivot_longer(dd, cols = c( "variable1", "variable2", "variable2", variable4), values_to = "Results", names_to = "Names")

A screenshot is really not very usefull. See FAQ: How to do a minimal reproducible example ( reprex ) for beginners

A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.