R data analysis, Introduction to data- 338-2/11

Screen Link: <!-- https://app.dataquest.io/m/338/working-with-control-structures/2/introduction-to-the-data->

My Code:

scores_five <- scores_five %>% mutate(home_team_won = home_team_won)

What I expected to happen: “home team won column should be created”

What actually happened:

 scores_fivetbl_dftbldata.frame (list)
actual
 	match_id	match_date	match_time	home_country	home_code	home_goals	away_country	away_code	away_goals	win_country	win_code	home_team_won
1	1	12 June	21:00:00	Brazil	BRA	3	Croatia	CRO	1	Brazil	BRA	home team won
2	2	13 June	17:00:00	Mexico	MEX	1	Cameroon	CMR	0	Mexico	MEX	home team won
3	3	13 June	20:00:00	Spain	ESP	1	Netherlands	NED	5	Netherlands	NED	home team won
4	4	13 June	23:00:00	Chile	CHI	3	Australia	AUS	1	Chile	CHI	home team won
5	5	14 June	17:00:00	Colombia	COL	3	Greece	GRE	0	Colombia	COL	home team did not win
expected
["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","
 	match_id	match_date	match_time	home_country	home_code	home_goals	away_country	away_code	away_goals	win_country	win_code	home_team_won
1	1	12 June	21:00:00	Brazil	BRA	3	Croatia	CRO	1	Brazil	BRA	home team won
2	2	13 June	17:00:00	Mexico	MEX	1	Cameroon	CMR	0	Mexico	MEX	home team won
3	3	13 June	20:00:00	Spain	ESP	1	Netherlands	NED	5	Netherlands	NED	home team did not win
4	4	13 June	23:00:00	Chile	CHI	3	Australia	AUS	1	Chile	CHI	home team won
5	5	14 June	17:00:00	Colombia	COL	3	Greece	GRE	0	Colombia	COL	home team won
"]

Hi @tosinoble, I see home_team_won created as a column in the output you provided so what is the error in your code that needs addressing. Could provide the rest of your code?

The error is with scores_five not home_team_won. I am trying to add home team won as a new column to scores five. So i used mutate () function.
scores_five <- scores_five > mutate(home_team_won = home_team_won)

Similar issue is happening in 9/11, trying to create home team result column in scores.
scores <- scores > mutate (home_team_result = home_team_result)

Thank you

Hi @tosinoble, your code should work if it is as in below image:

image

The error is with scores_five not home_team_won. I am trying to add home team won as a new column to scores five. So i used mutate () function.
scores_five <- scores_five > mutate(home_team_won = home_team_won)

Similar issue is happening in 9/11, trying to create home team result column in scores.
scores <- scores > mutate (home_team_result = home_team_result)
I used the same command you used but the output is not the expected output.
Thank you

Hi @tosinoble, you code was not passed by the grader because you placed "home team did not win" as the last item in the home_team_won vector. It should be the third item in the vector as below:

image

Thanks

Wow!! Thank you so much for your help.

You’re welcome @tosinoble! Could you please mark the response that addresses your questions as solution? If necessary, please refer to the following post on WHY and HOW to mark a post as solved: How do I mark a post as solved?

Happy learning!