I have a dataset with this structure:
df <- data.frame(
stringsAsFactors = FALSE,
Home = c("Huesca",
"Zaragoza","Real Sociedad B","Girona","Ponferradina",
"Sporting Gijón","Oviedo"),
Away = c("Eibar","UD Ibiza",
"Leganés","SD Amorebieta","Alcorcón","Burgos",
"Lugo"),
HomeGoals = c(2L, 0L, 1L, 2L, 1L, 1L, 2L),
AwayGoals = c(0L, 0L, 0L, 0L, 0L, 0L, 2L),
GD = c(2L, 0L, 1L, 2L, 1L, 1L, 0L),
score = c("2 - 0","0 - 0",
"1 - 0","2 - 0","1 - 0","1 - 0","2 - 2")
)
I want to create a new column, called FTR, populate with one of this values: H (if HomeGoals are larger than AwayGoals) , D(if Home and away are the same) or A(if AwayGoals are larger than HomeGoals). How can I get this?
Thanks in advance.