I have the following dataset. I want to create a column that checks for rows where only A has a positive number but the rest are 0s (ifelse assignment 1 or 0). Attached is the code below. I expect the columns to have all 0s except a "1" in the last row. Currently, I am getting a "0" for the rows. Any suggestions?
set.seed(111)
A <- rnorm(10,10,2)
B <- c(23,0,0,0,1,2,0,1,2,0)
C <- c(1,1,23,0,0,0,1,2,0,0)
D <- c(0,1,1,23,0,0,0,1,2,0)
df <- data.frame(A,B,C,D)
df$A.only <- ifelse(df$A > 0 && df$B == 0 && df$C == 0 && df$D == 0, 1, 0)