The documentation for str_split in the stringr package indicates that for the template argument:
If "" is split into individual characters.
which suggests that he behaves the same way as strsplit in this regard. Nevertheless,
library(stringr) str_split("abcab","") [[1]] [1] "" "a" "b" "c" "a" "b"
with leading blank line. This compares to
strsplit("abcab","") [[1]] [1] "a" "b" "c" "a" "b"
Leading blank lines appear to be normal behavior when breaking up non-empty lines,
strsplit("abcab","ab") [[1]] [1] "" "c"
but even then str_split creates the extra length of the empty string:
str_split("abcab","ab") [[1]] [1] "" "c" ""
Is this mismatch an error, a feature, an error in the documentation, or just another concept of "expected behavior"?
joran
source share