splitstackshape icon indicating copy to clipboard operation
splitstackshape copied to clipboard

throw error when the separator is ''

Open lilchow opened this issue 10 years ago • 1 comments

The concatenated column, 'response', in my data.table,'dt.gdoc' contains number string with no separator, e.g. "13464". I wanted to split this column into a list using

cSplit_l(dt.gdoc,'response',sep='',drop=T)

However, when I attempted to run this code, I got the following error:

Error in gsub(sprintf("\s+[%s]\s+|\s+[%s]|[%s]\s+", delim, delim,  : 
  invalid regular expression '\s+[]\s+|\s+[]|[]\s+', reason 'Missing ']''

lilchow avatar Jan 26 '15 02:01 lilchow

@lilchow, Thanks. I'll look into it. I'll probably need to add a stripWhite = FALSE argument like there is for cSplit.

mrdwab avatar Jan 26 '15 10:01 mrdwab