[R] match and incomparables
Adam D. I. Kramer
adik-rhelp at ilovebacon.org
Sat Sep 13 00:05:41 CEST 2008
I can replicate this and also do not understand it.
> match(1:3,1:3,incomparables=5)
[1] NA 2 3
> match(1:3,1:3,incomparables=4)
[1] 1 2 3
> match(1:3,1:3,incomparables=3)
[1] 1 2 3
> match(1:3,1:3,incomparables=2)
[1] 1 2 3
> match(1:3,1:3,incomparables=1)
[1] NA 2 3
...every other integer value for incomparables produces 1 2 and 3 for
output. I'm using R 2.7.2, self-compiled, under linux.
--Adam
On Fri, 12 Sep 2008, McGehee, Robert wrote:
> Hello,
> I was playing around with the newly implemented 'incomparables' argument
> in 'match' and realized the argument does not behave anything like I
> expected. Can someone explain what is going on here? Sorry if I'm
> misreading the documentation.
>
>> match(1:3, 1:3, incomparables=1)
> [1] NA 2 3 # This seems right, the 1 in 'x' is 'incomparable'
>
>> match(1:3, 1:3, incomparables=2)
> [1] 1 2 3 # Shouldn't this be 1 NA 3? Why isn't the 2 incomparable?
>
>> match(1:3, 1:3, incomparables=5)
> [1] NA 2 3 # Why isn't the 5 ignored?
>
> Note from ?match:
> "incomparables: a vector of values that cannot be matched. Any value in
> x matching a value in this vector is assigned the nomatch value. For
> historical reasons, FALSE is equivalent to NULL."
>
> Thanks in advance!
> Robert
>
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> status
> major 2
> minor 7.2
> year 2008
> month 08
> day 25
> svn rev 46428
> language R
> version.string R version 2.7.2 (2008-08-25)
>
> Robert McGehee, CFA
> Geode Capital Management, LLC
> One Post Office Square, 28th Floor | Boston, MA | 02109
> Tel: 617/392-8396 Fax:617/476-6389
> mailto:robert.mcgehee at geodecapital.com
>
>
>
> This e-mail, and any attachments hereto, are intended fo...{{dropped:12}}
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list