I have the following df:
>df
cluster_no days_to_port channel
1 1 2.8 MMR
2 2 4.1 Spark Retail Stores
3 3 2.4 Spark Retail Stores
4 4 3.0 Spark Retail Stores
5 5 3.5 Spark Retail Stores
channel_outlet_name region
1 PIN Distributor Ltd (Activata) Auckland - Central
2 Spark - Auckland Int Airport Mangere
3 Spark - Auckland Int Airport Mangere
4 Spark - Auckland Int Airport Mangere
5 Spark - Auckland Int Airport Mangere
I am trying to reshape/pivot this into the below format so that i could do some further conditional formatting and analysis: (so columns are cluster numbers and rows are the variables)
cluster_no 1 2 3 4 5
days_to_port
channel
channel_outlet_name
region
I could achieve using pivot in excel:
I would like to achieve the same using R.(BTW numeric values in df are mean values and categorical values are mode)