In this post, we will see how to resolve How to pivot a dataframe using dplyr
Question:
I’m trying to pivot this dataframe without success:apqual
as columns such that all the other values of the other columns referred to the same COD_REG
lie on a single row ( in my dataset you can notice that they are distributed on 2 rows)I mean this
pivot_longer
, but it seems I’m not able to set it correctly. Can anyone help me?Best Answer:
Since you’re increasing the number of columns, you want topivot_wider
:If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com