I am trying to recreate data pivoting with '.value' code:
source to original:
https://www.youtube.com/watch?v=qaksmQabMUI&list=PLmNrK_nkqBpL9STHqSod2LGwciLk9TXZ1,
11 minute.
I think I got everything in order to make it work but after pivoting I get Error:
'Expected 2 pieces. Missing pieces filled with `NA` in 2 rows [1, 2].'
Here is the data frame:
x y b_x b_y name
1 9010 10515 9020 10525 1
2 935 585 925 575 2
3 6825 7970 6835 7980 3
4 730 700 720 690 4
5 945 975 955 985 5
6 1565 1520 1555 1510 6
7 2120 1025 2110 1015 7
8 1520 1 1510 -9 8
9 985 1 975 -9 9
10 1360 1085 1350 1075 10
Than i run code as follow:
```{r}
data %>%
pivot_longer(
cols = -name,
names_to = c(".value", "pro"),
names_sep = "_"
)
name pro x y b
1 1 <NA> 9010 10515 NA
2 1 x NA NA 9020
3 1 y NA NA 10525
4 2 <NA> 935 585 NA
5 2 x NA NA 925
6 2 y NA NA 575
7 3 <NA> 6825 7970 NA
8 3 x NA NA 6835
9 3 y NA NA 7980
10 4 <NA> 730 700 NA
Expected 2 pieces. Missing pieces filled with `NA` in 2 rows [1, 2].