How to deal with character(0)

Let x <- character(0)
x == character(0) returns logical(0), which is not what we expect.

A solution is to test:
identical(x, character(0))

But it does not work if x has attributes.

Then, do:
attributes(x) <- NULL
identical(x, character(0))

or 


(length(x) == 0) && (typeof(x) == "character")

Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

Install treemix in ubuntu 20.04

stepAIC from package MASS with AICc