| tstrsplit {data.table} | R Documentation |
This is equivalent to transpose(strsplit(...)). This is a convenient wrapper function to split a column using strsplit and assign the transposed result to individual columns. See examples.
tstrsplit(x, ..., fill=NA, type.convert=FALSE)
x |
The vector to split (and transpose). |
... |
All the arguments to be passed to |
fill |
Default is |
type.convert |
|
It internally calls strsplit first, and then transpose on the result.
A transposed list.
x = c("abcde", "ghij", "klmnopq")
strsplit(x, "", fixed=TRUE)
tstrsplit(x, "", fixed=TRUE)
tstrsplit(x, "", fixed=TRUE, fill="<NA>")
DT = data.table(x=c("A/B", "A", "B"), y=1:3)
DT[, c("c1", "c2") := tstrsplit(x, "/", fixed=TRUE)][]