Rajasekaramya
2008-Sep-10 16:38 UTC
[R] comparing a list and vector and returnig the listname
hi, I have list of length 5453 and vector of length 14318.I need to compare the vector with the list and return the list name if matched.I am thinking of using an lapply but how to retrive the listname is wat i am puzzled abt. kindly let me know how to go abt it. Ramya -- View this message in context: http://www.nabble.com/comparing-a-list-and-vector-and-returnig-the-listname-tp19415038p19415038.html Sent from the R help mailing list archive at Nabble.com.
Henrique Dallazuanna
2008-Sep-10 16:42 UTC
[R] comparing a list and vector and returnig the listname
If I understand, try this: names(l[l %in% v]) where l is your list and v is your vector. On Wed, Sep 10, 2008 at 1:38 PM, Rajasekaramya <ramya.victory@gmail.com>wrote:> > hi, > > I have list of length 5453 and vector of length 14318.I need to compare the > vector with the list and return the list name if matched.I am thinking of > using an lapply but how to retrive the listname is wat i am puzzled abt. > kindly let me know how to go abt it. > > Ramya > -- > View this message in context: > http://www.nabble.com/comparing-a-list-and-vector-and-returnig-the-listname-tp19415038p19415038.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > 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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
Adam D. I. Kramer
2008-Sep-10 23:28 UTC
[R] comparing a list and vector and returnig the listname
Maybe, for vector v and list l match(v,names(l)) ? --Adam On Wed, 10 Sep 2008, Rajasekaramya wrote:> > hi, > > I have list of length 5453 and vector of length 14318.I need to compare the > vector with the list and return the list name if matched.I am thinking of > using an lapply but how to retrive the listname is wat i am puzzled abt. > kindly let me know how to go abt it. > > Ramya > -- > View this message in context: http://www.nabble.com/comparing-a-list-and-vector-and-returnig-the-listname-tp19415038p19415038.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > 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. >