r4strings icon indicating copy to clipboard operation
r4strings copied to clipboard

nchar() applied to an element with value NA

Open komwomak opened this issue 5 years ago • 1 comments

The text at the start of section 7.1 and the example do not appear to agree on what nchar() does on encountering NA:

text <- c("one", "two", "three", NA, "five") nchar(text) [1] 3 3 5 NA 4

Thank you for making this material available!

komwomak avatar Aug 13 '20 22:08 komwomak

It used to be true, but is no longer. This behavior changed around R 3.2.0 and is controlled by the keepNA parameter.

Ax3man avatar Nov 24 '21 01:11 Ax3man