R: Position of first NA

firstNA {bit} | R Documentation

## Position of first NA

### Description

This is substantially faster than `which.max(is.na(x))`

### Usage

    firstNA(x)

### Arguments

`x` | an R vector

### Value

a reversed vector

### See Also

`which.max`, `is.na`, `anyNA`, `anyDuplicated`, `bit_anyDuplicated`

### Examples

    x <- c(FALSE,NA,TRUE)
    firstNA(x)
    reverse(x)
    ## Not run:
    x <- 1:1e7
    system.time(rev(x))
    system.time(reverse(x))

    ## End(Not run)

[Package bit version 4.0.3 Index]