I've been trying to figure this out all day but to no avail. I have an if statement that is meant to satisfy four possible conditions.
- A exists and B does not exist
- B exists and A doesn't exist
- A & B exist
- A & B do not exist
A, B, C are dataframes.
Here is my code:
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}
I keep getting an error on unexpected "}" and unexpected "else". I've followed several examples but still facing this challenge. Any pointers would be much appreciated. Thx.