I want to create about 20 new dataframes, and I want the names of these dataframes to be 'matches_[country]' where [country] is the name of a country in countries_list. I thought a for loop would be the solution but I can't get it to work.
This is what I tried (results is the df):
countries_list = list('Netherlands', 'England', 'Brazil', 'Argentina', 'Germany', 'France', 'Spain', 'Italy', 'Portugal', 'Croatia', 'Uruguay', 'Mexico')
for (i in countries_list) {
matches_i = filter(results, home_team == 'i' | away_team == 'i')
}
With this, I thought I would get a dataframe for each of the countries in the list, with in each dataframe all the matches that that country played, either as the home or away team. However, it creates matches_i without any data.
Edit: Results is a table with international soccer matches, each match is a row and columns are date, home_team, away_team, home_score, away_score, tournament etc.
How could I solve this?