Data Science Desktop Survival Guide
by Graham Williams |
|||||
Concatenate NULL |
"hello" %s+% NULL %s+% "world"
str_c("hello", NULL, "world")
glue("hello", NULL, "world")
|
cat("hello", NULL, "world")
paste("hello", NULL, "world")
NA tends to be treated differently too. |
"hello" %s+% NA %s+% "world"
str_c("hello", NA, "world")
glue("hello", NA, "world")
cat("hello", NA, "world")
paste("hello", NA, "world")
The examples becomes more interesting in the context that the arguments to the functions might be string returning functions. If that function returns NULL or NA, purposely or accidentally then it is useful to know the consequences. |