String match
Please (re)-read the Help file for pmatch, which says: ... " (A partial match occurs if the whole of the element of x matches the beginning of the element of table.) " This is clearly not your situation. One approach (there may be others depending on what your detailed situation actually is) is to use regular expressions: ?regexp ?regexpr Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sat, Jun 4, 2016 at 10:28 AM, Christofer Bogaso
<bogaso.christofer at gmail.com> wrote:
Hi again,
I am facing trouble to match a vector strings. Let say I have below
full string vector
WhereToLook = c("ultracemco.bo.openam" , "ultracemco.bo.higham"
,"ultracemco.bo.lowam" , "ultracemco.bo.closeam" ,
"ultracemco.bo.volumeam" ,"ultracemco.bo.adjustedam")
WhatToLook = c("volume", "close")
Basically I need to find the positions of WhatToLook in WhereToLook.
So my code goes as below :
pmatch(tolower(colnames(WhereToLook)), WhatToLook)
integer(0) Although I was expecting my code would point 5 & 4 respectively. Appreciate if someone points as correct code for above case. Thanks,
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.