Transposing in dplyr
spread
is retired, tidyr
now suggests the usage of pivot_wider()
:
library(tidyverse)
df %>%
pivot_wider(names_from = HEADER, values_from = price)
I think you want tidyr
rather than dplyr
:
library(tidyr)
library(dplyr)
df %>% mutate(group = 1) %>%
spread(HEADER, price)
group AWAY_TEAM AWAY_TRPM HOME_TEAM HOME_TRPM
1 1 NOP -0.845186446996287 CHA 0.863104076023855
Using this, you can specify your groupings - and you can add on select(-group)
to remove them later.