I have the following data.frame
df = structure(list(HEADER = c(\"HOME_TRPM\", \"AWAY_TRPM\", \"HOME_TEAM\",\"AWAY_TEAM\"),
price = c(\"0.863
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.