I am having troubles converting a complicated data base output from its wide form to the long format. It has a couple of hundred rows and ~1,000 columns. It looks something like this:
The problem is that the variable of df1_long or the columns of df1_wide contain information that I want to select upon. So I rather want to have something like this:
ID part task subgroup type result
Ind_A a 12 aa 2 yes
Ind_A a 12 bb 2 yes
Ind_A b 12 aa 3 opt_1
Ind_A b 13 aa 4 100
Ind_B a 12 aa 2 no
Ind_B a 12 bb 2 yes
Ind_B b 12 aa 3 opt_2
Ind_B b 13 aa 4 50
Ind_C a 12 aa 2 no
Ind_C a 12 bb 2 no
Ind_C b 12 aa 3 opt_1
Ind_C b 13 aa 4 200
I dont mind that the numerical values/results get transformed into characters.
Is there a easy way to accomplish that with the stack() or reshape() function? Or do I have to code a function that performes some strsplits commands on the column names to extract the relevant information and then store those in separate new columns.
The long format will definitely be much more easy to work with and ask questions to the data set. Coding something for >1000 columns with those cryptic columns names just looks like a nightmare to me.