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

后端 未结 3 897
孤独总比滥情好
孤独总比滥情好 2020-11-28 10:48

I received the error

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

or

Error in while (condition) { : argument is          


        
3条回答
  •  猫巷女王i
    2020-11-28 10:51

    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.

提交回复
热议问题