【发布时间】:2020-08-05 04:01:27
【问题描述】:
我在 ideone.com (https://ideone.com/Z2pVQp ) 因为只有在您保存文件后,RStudio 才会在第 1、29、34、87 行旁边错误地显示不匹配的刹车警告标志。
由于该函数非常大,我将其全部发布在问题部分,但会给你例如第 29 - 34 行,这可能是这个问题的钩子。
missinggames <- map_df(1:nrow(missinggames), ~if(missinggames$Goals_team_home[.x] > missinggames$Goals_team_away[.x])
mutate(missinggames[.x,], points_team_home = 3, points_team_away = 0) else if
(missinggames$Goals_team_home[.x] == missinggames$Goals_team_away[.x])
mutate(missinggames[.x,], points_team_home = 1, points_team_away = 1) else
mutate(missinggames[.x,], points_team_home = 0, points_team_away = 3)
)
我在这里遗漏了什么或者我该如何解决这个问题?
【问题讨论】:
-
你能解释一下为什么或帮助我让它做它应该做的事情吗?
-
可能我错了。它可能有效,但你可以试试这个替代方案
missinggames %>% mutate(points_team_home = case_when(Goals_team_home > Goals_team_away ~3, Goals_team_home == Goals_team_away ~ 1, TRUE ~ 0), points_team_away = case_when(Goals_team_home > Goals_team_away ~0, Goals_team_home == Goals_team_away ~ 1, TRUE ~ 3))吗? -
非常好。我在脑海中寻找那个答案,但想不出。这也解决了刹车问题。