lundi 5 février 2018

logical(0) in if statement in R

This line:

which(!is.na(c(NA,NA,NA))) == 0

produces logical(0)

While this line

if(which(!is.na(c(NA,NA,NA))) == 0){print('TRUE')}

generates:

Error in if (which(!is.na(c(NA, NA, NA))) == 0) { : 
  argument is of length zero

Why there is an error? What is logical(0)

Aucun commentaire:

Enregistrer un commentaire