【发布时间】:2021-02-04 14:29:09
【问题描述】:
我有一个data.frame
Team Ability SE
Amur Khabarovsk Amur Khabarovsk 0.0000000 0.0000000
Sibir Novosibirsk Sibir Novosibirsk -0.2523662 0.7325424
Lokomotiv Yaroslavl Lokomotiv Yaroslavl 1.8614021 0.7883580
HC Red Star Kunlun HC Red Star Kunlun -1.2255611 0.9341483
HC Sochi HC Sochi -0.2862795 0.7735475
SKA St. Petersburg SKA St. Petersburg 0.9110674 0.6958989
我有这个功能
BT <- function(deltaa,deltab){
exp(deltaa-deltab) / (1 + exp(deltaa-deltab))
deltaa,deltab 将是 data.frame 中能力列的值,即
> BT( 1.8614021,1.6718526 )
[1] 0.547246
How do I put these values in BT(function), based on team column of data.frame?
我已经知道了,但是如何在不手动更改过滤器中的团队名称的情况下更改团队名称?
BT( home_team$Ability,away_team$Ability )
home_team <- filter(KHL_Abilities,Team==" Jokerit ")
away_team <- filter(KHL_Abilities, Team==" HC Sochi ")
> BT( home_team$Ability,away_team$Ability )
[1] 0.8763307
【问题讨论】:
标签: r function for-loop model subset