Re: [R] if else with 4 conditions problem

2018-05-27 Thread Rui Barradas
Hello, It's just a sequence of ifelse instructions. dat <- read.table(text = " A B 1 1 1 0 0 1 0 0 ", header = TRUE) dat$A1 <- ifelse(dat$A == 1 & dat$B == 1, 1, 0) dat$A2 <- ifelse(dat$A == 1 & dat$B == 0, 1,

[R] if else with 4 conditions problem

2018-05-27 Thread smart hendsome via R-help
Hi everyone, I have two columns:    A               B    1               1   1               0    0               1    0               0 I have 4 categories which are: 1) if A = 1 and B =1 then A1 = 1, else A2 = 0, A3 = 0, A4 = 0 2) if A = 1 and B =0 then A1 = 0, else A2 =1, A3 = 0, A4 = 0 3) if