I have a complicated long format dataset that I want t change into a wide one. The problem arises from one column beeing the “variable” column due to poor documentation done on Microsoft-Excel.
My dataset “Demografic” has the following three columns:
-
“VP”: (the code to identify participants) as a numeric variable
-
“Variable”: a character Variable encompassing 13 different demografic variables for every participant
-
“Value” the value for each variable in the second column, as a character variable
this it what the dataset looks like
(Alter = age, Geschlecht = gender, Abschluss = diploma)
Is there any way to just split the “variable” column so that I have one row for each participant and the variables as separate columns?
so it looks like this afterwards
Maybe converting one of the variables into a numeric/categorial one beforhand would help? Or is it better to change the dataset before importing it into r?
Feel free to further ask questions if my explanation wasn´t clear enough.
Leo Posanz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.