Error in if/while (condition) { : argument is of length zero

See ?NULL

You have to use is.null

‘is.null’ returns ‘TRUE’ if its argument is ‘NULL’ and ‘FALSE’
otherwise.

Try this:

if ( is.null(hic.data[[z]]) ) { print("is null")}

From section 2.1.6 of the R Language Definition

There is a special object called NULL. It is used whenever there is a need to indicate or
specify that an object is absent. It should not be confused with a vector or list of zero
length.
The NULL object has no type and no modifiable properties. There is only one NULL object
in R, to which all instances refer. To test for NULL use is.null. You cannot set attributes
on NULL.

Leave a Comment