0

I would like to create another column (novig_new) which contains the value of the Pinnacle bookmaker's novig_prob subtracted from the other bookmakers for each team. Here is my tibble:

Bookmaker odds

This is what I am looking to accomplish.

enter image description here

zephryl
  • 14,633
  • 3
  • 11
  • 30
Aaron Morris
  • 123
  • 6
  • 1
    Please use `dput` to show example data instead of images – akrun Feb 05 '23 at 21:53
  • Something like `data %>% group_by(team) %>% mutate(novig_prob = novig_prob[bookmaker == "Pinnacle"] - novig_prob) %>% ungroup()`. If that doesn’t work, please share your data in copy-pasteable form using `dput(data)`. Also have a look at [How to make a great R reproducible example](https://stackoverflow.com/q/5963269/17303805). – zephryl Feb 05 '23 at 21:55

1 Answers1

1

Perhaps, we may need

library(dplyr)
df1 %>%
   group_by(team) %>%
   mutate(novig_new = novig_prob - novig_prob[match("Pinnacle", bookmaker)]) %>%
  ungroup
akrun
  • 874,273
  • 37
  • 540
  • 662