R:ifelse语句,将值分配给另一列

Based on three conditions I want to assign the value 1. The following code works if I use only one & (so for example leave out 2018).

df[df$2017 == 1 & 
   df$2018 == 0 &
   df$x == -1, ]$y <- 1

I believe an ifelse statements is what I need, but I don't understand how to assign value 1 to column y within the statement.

非常感谢帮助