Skip to content
Prev 57854 / 63424 Next

A weird behaviour of strsplit?

On 18/12/2019 9:42 a.m., IAGO GIN? V?ZQUEZ wrote:
Yes, you are misunderstanding the help.  Your input x has length 1, so 
only the first element of split will be used.  If you wanted to use 
both, you would need a longer x.  For example,

 > strsplit(c("1:2", "3:4"), split=c(",", ":"), fixed=TRUE)
[[1]]
[1] "1:2"

[[2]]
[1] "3" "4"

The first element is split using "," -- since there are none, there's no 
splitting done.  The second element is split using ":".

Duncan Murdoch