I used the pivot_wider function to transpose a dataframe from:
metric shop1 shop2 shop3 shop4
sales 10 12 14 16
county orange sperling wood riverside
Using this code:
df_new <- pivot_wider(df,
cols = c("shop1", "shop2",
"shop3", "shop4"),
cols = shop)
I got the following:
measure name value
sales shop1 10
sales shop2 12
sales shop3 14
sales shop4 16
county shop1 orange
county shop2 sperling
county shop3 wood
county shop4 riverside
I was hoping to have separate columns for sales, county, and shop. How do I do that?