R Ifelse: Find if any column meet the condition
问题 I'm trying to apply the same condition for multiple columns of an array and, then, create a new column if any of the columns meet the condition. I can do it manually with an OR statement, but I was wondering if there is an easy way to apply it for more columns. An example: data <- data.frame(V1=c("A","B"),V2=c("A","A","A","B","B","B"),V3=c("A","A","B","B","A","A")) data[4] <- ifelse((data[1]=="A"|data[2]=="A"|data[3]=="A"),1,0) So the 4th row is the only that doesn't meet the condition for