b@mith030465 @ending from gm@il@com
Mon Jul 16 19:46:20 CEST 2018
I was trying to find a pattern ("ABHD14A") in a character string ('xgen' in
example below) using grepl. Note that the individual members may be
separated by a semi-colon.
The correct answer should return:
"ABHD-ACY1 ; ABHD14A" "ABHD14A ; YYY"
I have tried three approaches, but still seem a bit off. Attempt 2 below
gets closest, but it also returns a hit where my pattern is a substring.
Here is my code:
xgen <- c("XYZ","ABHD-ACY1 ; ABHD14A","ABHD14AXX","ABHD14A ; YYY")
ga <- "ABHD14A"
kx <- grepl(paste0("^",ga,"$"),xgen)
ky <- grepl(ga,xgen)
What do I need to add/change in #2 above?
[[alternative HTML version deleted]]
More information about the R-help