r4strings
r4strings copied to clipboard
nchar() applied to an element with value NA
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!
It used to be true, but is no longer. This behavior changed around R 3.2.0 and is controlled by the keepNA parameter.