valid_na_index: Validate the declared missing values index

valid_na_indexR Documentation

Validate the declared missing values index

Description

Check whether every position stored in the na_index attribute identifies a genuine missing value in the vector. This can detect when external code has changed a vector without refreshing its declared missing values metadata.

Usage

valid_na_index(x)

Arguments

x

An atomic vector, possibly containing an na_index attribute.

Details

The check examines only the positions in na_index and stops at the first invalid position. A missing or empty na_index attribute is valid.

Value

A logical value. TRUE when every indexed value is a genuine NA; otherwise FALSE.

Examples

x <- declared(c(1, -1, 3), na_values = -1)

valid_na_index(x)

attr(x, "na_index") <- 1
valid_na_index(x)

declared documentation built on Aug. 22, 2026, 9:07 a.m.