Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread Kehl Dániel
Dear Witold, as a first hint: read posting guide please! People are answering in their free time, so please try to be polite! For your first problem: what are you expecting? You have a dataset where most of the values is missing, the others all 0's most of the time, and some Inf values as

Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread PIKAL Petr
Hi which(table == match) or which(table %in% match) Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Witold E Wolski Sent: Monday, February 03, 2014 11:19 AM To: r-help@r-project.org Subject: [R] match - returns a

Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread Witold E Wolski
Hi Petr, I was actually citing the match (%in%) docu - match returns the positions of (first) matches. I am looking for something returning ALL matches (sure it's easy to write a function which does it ... my intuition however is, that there is already such a function in R - is there something

Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread PIKAL Petr
Hi Posting questions without context may result in answers unrelated to your problem. Anyway it works for me without problem table-sample(letters[1:5], 20, replace=T) which(table %in% a) [1] 1 2 19 version _ platform i386-w64-mingw32 arch i386 os

Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread Witold E Wolski
Thank you. That's what I was looking for. I am wondering what does the documentation means by (first) than? match {base} match returns a vector of the positions of (first) matches of its first argument in its second. On 3 February 2014 15:02, PIKAL Petr petr.pi...@precheza.cz wrote: Hi

Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread PIKAL Petr
Hi If you are in doubt, try it. It is usually easy and does not do any harm. test-sample(letters[1:5], 20, replace=T) match(test,c) [1] NA NA NA 1 1 NA 1 1 NA NA NA 1 1 NA NA NA NA NA NA NA match(c, test) [1] 4 First occurence of c is at 4th position of test vector. There are others but

Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread William Dunlap
table-sample(letters[1:5], 20, replace=T) which(table %in% a) [1] 1 2 19 How is this different than which( table == a) ? The latter is probably a tad faster. I thought the OP had 2 vectors, x and table, and wanted a list the length of x, such that the i'th element of the list gave the