lundi 30 mai 2016

Why `intersect` syntax does not work in R in an `if statement`?

I know the syntax of an IF statement in R:

if (1==1){
  print("this is true")
}

And I know that the stuff between the () should be evaluated to a logical. So, when I try this:

if (intersect(list(1),list(1,2)) != list()){
  print("this is also true")
}

I expected it to work, since the intersect(list(1),list(1,2)) != list() is evaluated as a logical type:

intersect(list(1),list(1,2)) == list()

Am I doing something obviously wrong? Thanks.

Aucun commentaire:

Enregistrer un commentaire