I have a data frame resembling the extract below:
Observation Identifier Value
Obs001 ABC_2001 54
Obs002 ABC_2002 -2
Obs003
You could try the below sub
command to remove all the non-space characters from _
symbol.
sub("_\\S*", "", string)
Explanation:
_
Matches a literal _
symbol.\S*
Matches zero or more non-space characters.OR
This would remove all the characters from _
symbol,
sub("_.*", "", string)
Explanation:
_
Matches a literal _
symbol..*
Matches any character zero or more times.