I have a variable, a, it contains characters like :
DEVICE PRF .75MG 0.5ML
DEVICE PRF 1.5MG 0.5MLX4
CAP 12-25MG 30
CAP DR 60MG 100UD 3270-33 (32%)
I would like to split them into three parts(or variables):
x y z
DEVICE PRF .75MG 0.5ML
DEVICE PRF 1.5MG 0.5MLX4
CAP 12-25MG 30
CAP DR 60MG 100UD 3270-33 (32%)
The first part is the description, the second is the strength, and the third part is the volume. I think I can use gregexpr(), but not sure how to implement it. Any suggestions are appreciated. Thank you!
Using the assumption that the middle part has no spaces and always starts with a
.
or digit, we can do this in base R like this: