Multiple If Statements in R

try this

if (!exists("A") & exists("B")) {
    C= B
} else if (exists("A") & !exists("B")) {
    C= A
} else if (exists("A") & exists("B")) {
    C= rbind(B,A)
} else {C <- NULL}

Leave a Comment