Closed hadley closed 6 years ago
Hmm... paste()
behaves more like a vectorized arithmetic operator, say, +
, and not an aggregation function, say sum()
So I don't think this function should get rid of any strings
Maybe you mean the stri_flatten()
function?
Except when collapse
is non-NULL. And pmin()
and pmax()
have na.rm
arguments
Thanks for pointing out that
> pmax(c(NA, 1), c(5, 5))
[1] NA 5
> pmax(c(NA, 1), c(5, 5), na.rm=TRUE)
[1] 5 5
I'm adding this to stri_flatten
> stri_flatten(c(NA, "", "A", "", "B", NA, "C"), collapse=",", na_empty=TRUE, omit_empty=TRUE)
[1] "A,B,C"
> stri_flatten(c(NA, "", "A", "", "B", NA, "C"), collapse=",", na_empty=TRUE, omit_empty=FALSE)
[1] ",,A,,B,,C"
> stri_flatten(c(NA, "", "A", "", "B", NA, "C"), collapse=",", na_empty=FALSE, omit_empty=TRUE)
[1] NA
And I added stri_remove_empty
and stri_na2empty
funs
Thanks, My earlier concept had a somewhat similar idea. " Safe concatenation/comparison operator #292 " The original idea was because if I do I concatination
... string ... + if(){ } + ... string ...
and "if()" is not TRUE, then, if(){ } silently returns a NULL, and that NULL wreaks havoc in string concatination.
Since it treats
NA
s like other summary functions.