Looking for a build in function which returns a vector of the
positions of _ALL_ matches.
--
Witold Eryk Wolski
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
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
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
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
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
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
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
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
8 matches
Mail list logo