Skip to contents

A causal_idx list is a list with integer vector entries which represent indices in some other object (like a data frame). Generically it can be used to represent a graph structure, such as an interference network or a collection of matched objects. The main feature of causal_idx is that the index references are preserved through slicing and reordering. Indices that no longer refer to elements (because of subsetting) are set to NA.

Usage

causal_idx(x = list())

new_causal_idx(x = list())

is_causal_idx(x)

as_causal_idx(x)

Arguments

x
  • For causal_idx() and new_causal_idx(): A list of indices

  • For is_causal_idx(): An object to test

  • For as_causal_idx(): An object to coerce

Value

A causal_idx object. For is_causal_idx(), a logical value.

Functions

  • new_causal_idx(): Construct a causal_idx list with minimal checks

  • is_causal_idx(): Return TRUE if an object is an causal_idx list

  • as_causal_idx(): Coerce an object to an causal_idx list

Examples

idx <- causal_idx(list(2, c(1, NA, 3), 2))
print(idx)
#> <causal_idx[3]>
#> [1] (2)   (1,3) (2)  
idx[1:2] # subsetting
#> <causal_idx[2]>
#> [1] (2) (1)
idx[c(2, 1, 3)] # reordering
#> <causal_idx[3]>
#> [1] (2,3) (1)   (1)