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
Enregistrer un commentaire