I trying to check if two variables have the same sign this is the code I am using.
a <- c(0)
x1 <- x/abs(x)
y1 <- y/abs(y)
if(x1==y1) {
a <- x + y
} else {
a <- x - y
}
But I get the error
Error in if (x1 == y1) { : missing value where TRUE/FALSE needed
What am I doing wrong? Is there a more efficient way to check the signs?
Aucun commentaire:
Enregistrer un commentaire