英文:
How can I subtract a value from a column B based upon a string value of column A
问题
我想要创建另一列(novig_new),其中包含 Pinnacle 书maker 的 novig_prob 值减去其他书maker 对每支球队的值。这是我的 tibble:
这是我想要实现的目标。
英文:
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:
This is what I am looking to accomplish.
答案1
得分: 1
或许,我们可能需要
library(dplyr)
df1 %>%
group_by(team) %>%
mutate(novig_new = novig_prob - novig_prob[match("Pinnacle", bookmaker)]) %>%
ungroup
英文:
Perhaps, we may need
library(dplyr)
df1 %>%
group_by(team) %>%
mutate(novig_new = novig_prob - novig_prob[match("Pinnacle", bookmaker)]) %>%
ungroup
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论