I have a dataset like this:
structure(list(INDEX1 = c(60L, 83L, 10L, 11L, 11L, 54L, 27L),
status = c("Y", "N", "Y", "Y", "N", "N", "Y"), index2 = c(12L,
11L, 12L, 14L, 17L, 11L, 8L)), class = "data.frame", row.names = c(NA,
-7L))
INDEX1 status index2
60 Y 12
83 N 11
10 Y 12
11 Y 14
11 N 17
54 N 11
27 Y 8
I want to make a column (index3) that keep values of index1 if status =="Y" and add the values of index2 if status=="N".