I have a large dataset (4000 participants (rows), 150 columns). The columns are not necessarily variables but in the columns is information on the participant. I want to remove the NA data from the columns and thereby combine different columns.
For example if i have a dataset:
V1 V2 V3 V4
P1 K1 NA K9 K10
P2 NA K8 NA NA
P3 K7 K0 K3 NA
P4 K2 NA NA NA
P5 NA NA NA K8
I want the result to look like this:
V1 V2 V3
P1 K1 K9 K10
P2 K8 NA NA
P3 K7 K0 K3
P4 K2 NA NA
P5 K8 NA NA
I tried different options with the dyplr package the mutate and apply functions but so far I only managed to put everything in one columns instead of keeping the separate columns still
Robin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.