Fundamentals of string manipulation. R. Screen 8

Screen Link:

My Code:

win_goals <- if_else (scores$home_goals > scores$away_goals, scores$home_goals, scores$away_goals)
lose_goals <- if_else (scores$home_goals < scores$away_goals, scores$home_goals, scores$away_goals)
scores <- scores %>%

What I expected to happen:

Nice work! Next screen >

What actually happened:

*Actual* do not match *expected* though it seems that they should match

Hello @ideainahead. The code provided above does not account for ties. Using the win_goals variable for example… if home_goals is greater than away_goals the value of scores$home_goals is assigned. Otherwise, (i.e. “else”) the value of scores$away_goals is assigned. But a tie between scores$home_goals and scores$away_goals does not meet the condition:
scores$home_goals > scores$away_goals
This causes ties to be pulled in here as well.
You were on the right track though. With that said, unfortunately, even accounting for ties will not result in the correct answer for this exercise because of the way this dataset is setup. There are a few instances in this dataset where the scores indicate a tie, but there is an assigned winner. This is known issue, and an old mission. We are in the process of re-writing this content.

Thanks @casey! Got it!

1 Like