'How can I add new column with ifelse

I am a beginner of R studio. Here is the data below.

logic1 logic2 logic3
TRUE FALSE FALSE
FALSE FALSE FALSE
TRUE FALSE FALSE
TRUE TRUE TRUE
TRUE FALSE FALSE
FALSE TRUE FALSE
TRUE FALSE FALSE
TRUE FALSE FALSE
FALSE FALSE TRUE
TRUE FALSE FALSE
TRUE FALSE FALSE

I'd like to add a new data column on the right. If (logic1, logic2, logic3) is (TRUE, FALSE, FALSE), add TRUE. If not, add FALSE. For this, I made code like the below.

x <- c(df2$logic1, df2$logic2, df2$logic33)
y<- c(TRUE, FALSE, FALSE)
x1 <- ifelse(x %in% y, TRUE, FALSE)
df2$result <- x1

However, the Rstudio result shows like below.

Error in `$<-.data.frame`(`*tmp*`, result, value = c(TRUE, TRUE, TRUE, : 
replacement has 22 rows, data has 11

I've tried to find various ways in Google, but I couldn't find the way.

r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source