I would like to 'tidy' my data so that I can carry out analysis from a table that looks like this:
| day | room_1 | room_2 | temp_1 | temp_2 | press_1 | press_2 | out_temp | out_press |
|---|---|---|---|---|---|---|---|---|
| 1 | dyson | vulcan | 12 | 7 | .7 | .5 | 21 | .6 |
| 2 | dyson | vulcan | 10 | 5 | .3 | .6 | 19 | .4 |
and I want to transform the data to the following 'tidy' format:
| day | room | temp | press | out_temp | out_press |
|---|---|---|---|---|---|
| 1 | dyson | 12 | .7 | 21 | .6 |
| 2 | dyson | 10 | .3 | 19 | .4 |
| 1 | vulcan | 7 | .5 | 21 | .6 |
| 2 | vulcan | 5 | .6 | 19 | .4 |
My actual data contains 8 'rooms', 10 different variables for each 'room', and up to 200 'days' of observation. Once tidied, I expect to have tens of thousands of rows.
I have tried to use pivot_longer() but I can't manage to come up with a Regex to help separate and group column names.
I appreciate any help I can get.