Trying to run a function that will run a calculation IF the two vectors have values (aka if they are not empty).
Basically I want the "answer" to be 3 in the example below but if VAR1 or VAR2 was empty/had no value I would want the answer to be "limited".
I am using the function is.na but it currently wont work since one of my variables is a character...
VAR1 = 1
VAR2 = "Yes"
if (!is.na(VAR1 | VAR2)) {
Answer = Var1 + 2
} else (Answer = "limited")
GET THE ERROR
Error in VAR1 & VAR2 :
operations are possible only for numeric, logical or complex types
You can use something like: