Skip to contents

Identify missing values in a price index.

Usage

# S3 method for piar_index
is.na(x)

# S3 method for piar_index
anyNA(x, recursive = FALSE)

Arguments

x

A price index, as made by, e.g., elemental_index().

recursive

Check if x also has missing percent-change contributions. By default only index values are checked for missingness.

Value

is.na() returns a logical matrix, with a row for each level of x and a columns for each time period, that indicates which index values are missing.

anyNA() returns TRUE if any index values are missing, or percent-change contributions (if recursive = TRUE).

Examples

index <- as_index(matrix(c(1, 2, 3, NA, 5, NA), 2))

anyNA(index)
#> [1] TRUE
is.na(index)
#>       1     2     3
#> 1 FALSE FALSE FALSE
#> 2 FALSE  TRUE  TRUE

# Carry forward imputation

index[is.na(index)] <- 1
index
#> Period-over-period price index for 2 levels over 3 time periods 
#>   1 2 3
#> 1 1 3 5
#> 2 2 1 1