Section 30 Vector: Nonsensical Coercion

30.1 Non-sensical coercion

Sometimes, R cannot figure out how to coerce an object and this can result in NA being produced.

When nonsensical coercion takes place, R gives a warning.

Warning: NAs introduced by coercion

30.2 Example: Nonsensical coercion

x <- c("a", "b", "c")
as.numeric(x)
as.logical(x)
as.complex(x)