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
123:34:56:78 -100
87:65:43:21 -200
a4:b6:c8888 -300
11:bbbb:ccccc -400
uu:vv:ww:xx -500', header = TRUE)
desired.result <- read.table(text='
my.string1 my.string2 my.string3 some.data
123 34 56:78 -100
87 65 43:21 -200
a4 b6 c8888 -300
11 bbbb 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.
EDIT:
The number of characters before the first colon is not always two and the number of characters between the first two colons is not always two. So, I edited the example to reflect this.