s-u / fastmatch

Fast hashing functions and replacement of match()
18 stars 7 forks source link

NA match #6

Closed skanskan closed 7 years ago

skanskan commented 7 years ago

Hello.

The reason I use base's %in% or match commands is because it makes easy to match values no matter they are numbers, characters or even NAs.

match(c(1,0,NA),NA)   NA, NA, 1
c(1,0,NA) %in% NA  gives  FALSE, FALSE, TRUE

I specially like the latter one.

But fmatch(c(1,0,NA),NA) gives NA, NA, NA (useless)

If fastmatch is supposed to improve base::match I think it should mimic it's behaviour with NA.

s-u commented 7 years ago

Sorry, but I get

> library(fastmatch)
> fmatch(c(1,0,NA),NA)
[1] NA NA  1

Can you, please, supply details on versions (R + fastmatch + OS) and platform?

joshuaulrich commented 7 years ago

The latest version of fmatch in the repository already does what you want. You're probably using the CRAN version.

R> match(c(1, 0, NA_real_), NA_real_)
[1] NA NA  1
R> fastmatch::fmatch(c(1, 0, NA_real_), NA_real_)
[1] NA NA  1
R> packageVersion("fastmatch")
[1] '1.1.0'

Using the version on CRAN:

R> match(c(1, 0, NA_real_), NA_real_)
[1] NA NA  1
R> fastmatch::fmatch(c(1, 0, NA_real_), NA_real_)
[1] NA NA NA
R> packageVersion("fastmatch")
[1] '1.0.4'
s-u commented 7 years ago

I guess it's time to push it to CRAN ;)

skanskan commented 7 years ago

OK, now it works, thanks.