I have a table like this
id name value
1 PROD_N NA
2 PROD_N_NATIONAL 0.789
3 PROD_N1 0.5
4 PROD_N1_NATIONAL 0.2
5 PROD_N2 0.4
6 PROD_N2_NATIONAL 0.3
7 PROD_N3 NA
8 PROD_N3_NATIONAL 0.221
9 PROD_N4 0.2
10 PROD_N4_NATIONAL 0.391
I need something like that (in order to make a gg plot grouped bar with fill).
ID year prod prod_national
1 2020 NA 0.789
2 2019 0.5 0.2
3 2018 0.4 0.3
4 2017 NA 0.221
5 2016 0.2 0.391
I'm almost sure I should use pivot_wider but I can't manage to achieve that. I always end with
id prod_n prod_n_national prod_n1 prod_n1_national ...
Also, it's another problem but even with the desired table I'm not sure how to be able to plot two 'y' value in the same graph. But I'll see when I'll be there.
Thanks for any tips !