Assume that I have a df similar to this:
# A tibble: 5 x 6
x1 x2 x3 y1 y2 y3
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 4 3 2 4 3 2
2 4 3 2 4 3 2
3 4 3 2 4 3 2
4 4 3 2 4 3 2
5 4 3 2 4 3 2
Is there a way to create a tibble with the columns x, y, z in a single pivot_longer comand?, right now I'm using a pivot_longer line for each group of columns but I'm sure there is an easier way to get it.
x y z
<dbl> <dbl> <dbl>
1 4 4 1
2 4 4 1
3 4 4 1
4 4 4 1
5 4 4 1
6 3 3 2
7 3 3 2
8 3 3 2
9 3 3 2
10 3 3 2
11 2 2 3
12 2 2 3
13 2 2 3
14 2 2 3
15 2 2 3