I have a dataframe with the following format:
time | emg | eda |
---|---|---|
Stimulus 80 | NA | NA |
NA | NA | NA |
Onset time | MAX (ch4) | MAX (ch7) |
131.84450000000001 | 8.6929632579550682 | 7.8114367391085029 |
142.83000000000001 | 2.062198261793945 | 9.0520476734366273 |
150.60149999999999 | 2.8645742403188507 | 8.6158402220299344 |
NA | NA | NA |
Stimulus 10 | NA | NA |
NA | NA | NA |
Onset time | MAX (ch4) | MAX (ch7) |
134.25999999999999 | 1.4936528696982108 | 8.6331626452321366 |
This table goes on for about 10 more stimuli, and the amount of rows per stimulus is variable. Is there a way in which I can move the rows that belong to specific stimuli to new columns? I want to do it in such a way that if I get another one of these dataframes, that I can run the code again and format the table without having to check how many rows each stimulus has.
The way I want the table to be formatted is going to be like this:
time | emg80 | eda80 | emg10 | eda10 |
---|---|---|---|---|
131.84450000000001 | 8.6929632579550682 | 7.8114367391085029 | NA | NA |
134.25999999999999 | NA | NA | 1.4936528696982108 | 8.6331626452321366 |
142.83000000000001 | 2.062198261793945 | 9.0520476734366273 | NA | NA |
150.60149999999999 | 2.8645742403188507 | 8.6158402220299344 | NA | NA |
I don't even know if this is possible, but I'd really appreciate anyone who can help me out somewhat.