Hi, I have a large matrix of data with column names like this:
ABCD-123A-1234-AB1AB1
I would like to short these to
ABCD-123A
Unfortunately the second part (123A) is 4 or 5 characters so I can't cut it by length?
Is there a way to use gsub to sub everything from the second - for ""? Or another solution?
Thanks so much this worked! I was wondering if you could break down how this works so I can alter it for future use? I'm guessing split is where to cut and the n=2 is saying split at the 2nd instance? But I'm not sure about the collapse part? Or if you have a good resource instead on this that would be great