df$score_diff <- df$score1 - df$score2
df$seed_diff <- df$seed1 - df$seed2
df
I created two variables "score_diff" and "seed_diff", I would like to create a binary variable which is defined by if the the score_diff is <0 and if the seed_diff is greater than 5.
df$upset <- ifelse(df$score_diff < 0 & df$seed_diff > 5)
I tried this, however it didn't work, I am new to this so bear with me.
CodePudding user response:
df$upset <- ifelse(df$score_diff<0 & df$seed_diff>5, 1, 0)
CodePudding user response:
df$upset <- as.integer(df$score_diff < 0 & df$seed_diff > 5)