I have a column of strings that's like this:
|Image
|---
|CR 00_01_01
|SF 45_04_07
|ect
I want to get an end result of this:
| Condition | Time |
| --- | --- |
| CR | 00 |
I have 2 steps of doing this but it's very cumbersome. Essentially, I split the string twice first using space and second using _.
df <- df[, c("Condition","T") := tstrsplit(Image, " ", fixed=T)]
df <- df[, c("Time") := tstrsplit(T, "_", fixed=TRUE, keep = 1L)]
Is there any better way of doing this?