Grokbase Groups R r-help June 2016
FAQ

try this:


WhereToLook = c("ultracemco.bo.openam" , "ultracemco.bo.higham"
+ ,"ultracemco.bo.lowam" , "ultracemco.bo.closeam" ,
+ "ultracemco.bo.volumeam" ,"ultracemco.bo.adjustedam")
WhatToLook = c("volume", "close")

# create pattern match
pat <- paste(WhatToLook, collapse = "|")
grep(pat, WhereToLook)
[1] 4 5








Jim Holtman
Data Munger Guru


What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Sat, Jun 4, 2016 at 1:28 PM, Christofer Bogaso 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.

  [[alternative HTML version deleted]]

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
groupr-help @
categoriesr
postedJun 4, '16 at 5:28p
activeJun 4, '16 at 8:15p
posts3
users3
websiter-project.org
irc#r

People

Translate

site design / logo © 2018 Grokbase