I have a string of 7 dimensions that I want to split into 7 different strings. The string is comma delimited, i.e. there is a comma between each of the dimensions. Ordinarily, to separate the dimensions into different strings, I would just use the separate function and specify that sep = ", ". However, one of my dimensions is a string that in some instances contains a comma, which makes the above method obsolete. Is there a way to potentially conditionally separate the string or a different regex pattern that I could use to still separate the dimensions while maintaining the proper values for each dimension?
Here is a sample of the issue that I am dealing with. Below is an example of the kind of string that I am working with. I have the dimension name, followed by a colon, followed by the value for that dimension. Note that I do not need assistance separating the dimension name from the value, I already have a solution for that:
my_str <- "dim1: 1, dim2: a, b, dim3: 3"
As you can see, dim2 has a value of a, b so if I use the separate() function with sep = ", ", I end up with the following three strings:
"dim1: 1"
"dim2: a"
"b "
when what I want is
"dim1: 1"
"dim2: a, b"
"dim3: 3"