Displaying 1 result from an estimated 1 matches for "2ghx".
Did you mean:
2gh
2010 Jul 16
2
Deleting a variable number of characters from a string
...ring in which I need to delete a variable number of characters from the string. The string itself contains the number of characters to be deleted. The number of characters to be deleted is proceeded by either a "+" or a "-".
A toy example:
Suppose I have
x<-c("A-1CB-2GHX", "*+11gAgggTgtgggH")
> x
[1] "A-1CB-2GHX" "*+11gAgggTgtgggH"
What I need as output is
"ABX" "*H"
I know I can use gsub to remove the control character and the number portion with
gsub("(\\-|\\+)([0-9]+)", replacement=&quo...