I have data.frame as follows
> df
ID Value
A_001 DEL-1:7:35-8_1
A_002 INS-4l:5_74:d
B_023 0
C_891 2
D_787 8
E_865 DEL-3:65:1s:b
Just remove the character class and add .*
next to that group. sub
alone would do this job.
df$value <- sub("^(DEL|INS).*", "", df$value)
Inside a character class, each char would be treated speartely not as a whole string. So [DEL]
would match a single character from the given list, it may be D
or E
or L
.
First letter is not digital:
df$value <- gsub("^\\D.*", "", df$value)
Or there is '-' in delete value:
df$value <- gsub(".*-.*", "", df$value)