Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
str_trunc can't handle NA's in input #162
Passing a single
NA_character_ %>% str_trunc(10)
But a vector with one or more NA's throws an error
c("foo bar baz", NA) %>% str_trunc(10) c(NA_character_, NA_character_) %>% str_trunc(10)
which happens without piping, as well.
It seems like the expected behaviour would be to truncate the "real" strings, and leave the NA's untouched, rather than throw an error.
(Not the dev version, but git blame suggests this function hasn't changed in two years)