Split string on first two colons
- by Mark Miller
I would like to split a column of strings on the first two colons, but not on any subsequent colons:
my.data <- read.table(text='
my.string some.data
12:34:56:78 -100
87:65:43:21 -200
a4:b6:c8888 -300
11:bb:ccccc -400
uu:vv:ww:xx -500', header = TRUE)
desired.result <- read.table(text='
my.string1 my.string2 my.string3 some.data
12 34 56:78 -100
87 65 43:21 -200
a4 b6 c8888 -300
11 bb ccccc -400
uu vv ww:xx -500', header = TRUE)
I have searched extensively and the following question is the closest to my current dilemma:
Split on first comma in string
Thank you for any suggestions. I prefer to use base R.