Skip to content
Prev 25873 / 63424 Next

hasNA() / anyNA()?

On Tue, 2007-08-14 at 07:48 -0400, Benjamin Tyner wrote:
It does not save anything:

Vec1 <- c(NA, rep(1, 10000000))

Vec2 <- c(rep(1, 10000000), NA)
user  system elapsed 
  1.053   0.217   1.404
user  system elapsed 
  1.049   0.242   1.360 

Note, there is no difference in execution time between the two. Review
the source code for match() in unique.c and you will see why.


Now try:
user  system elapsed 
  0.242   0.079   0.358
user  system elapsed 
  0.255   0.067   0.321 


Still essentially no time difference, but notably faster than using
match(). To get much faster, you would likely need to code a new
function in C, patterned after Kurt's reply.

HTH,

Marc Schwartz