nested if else statement in r programming