Problem with if statement in R

I am developing a R shiny application. I have a problem in if Loop.

I have code as following.

if (input$league !="anything"){
data <- data[(data$home_team | data$away_team) == input$league,]


The problem is Error in |: operations are possible only for numeric, logical or complex types. but it works in the loop if I do not have or(||) condition

You need to write it in this way: a==league | b==league.

Otherwise the left side is a logical vector.

(Witting from mobile...)