You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using tstrsplit() with a number of new variables created by the split less than the number of occurrences of the chosen delimiter, everything after the last new variable is removed, instead of contained in the last new variable.
# load and create data
library(data.table)
DT <- data.table(
string=c('this is xcutx a nice string', 'this is xcutx also a nice string xcutx whith a little problem'),
id=1:2)
# assigningen to two variables. observation two has three cutpoints with the chosen delimiter
DT[,(c('V1','V2')):= tstrsplit(string, 'xcutx')]
in the second observation, because it has 2 cutpoints, everything after the second cut is removed. I would think this is a undesirable result for most users.
when using stri_split_regex() from the stringi-package you can set the n-argument and get the expected result:
Hi,
When using tstrsplit() with a number of new variables created by the split less than the number of occurrences of the chosen delimiter, everything after the last new variable is removed, instead of contained in the last new variable.
Like this:
#
Minimal reproducible example
in the second observation, because it has 2 cutpoints, everything after the second cut is removed. I would think this is a undesirable result for most users.
when using stri_split_regex() from the stringi-package you can set the n-argument and get the expected result:
by transposing, just as tstrsplit, the function can be used inside data.table:
#
Output of sessionInfo()
The text was updated successfully, but these errors were encountered: