indexed: A simple class for indexed data.

View source: R/table1.R

indexedR Documentation

A simple class for indexed data.

Description

A simple class for indexed data.

Usage

indexed(x, i, ...)

Arguments

x

An atomic vector or data.frame.

i

An optional vector of indices (dafaults to 1:n, where n is the number of elements in x).

...

Other arguments passed to methods.

Value

An object identical to x but with the additional class indexed and a indices attribute.

Examples

x <- c(3.7, 3.3, 3.5, 2.8)
y <- c(1, 2, 1, 2)

z <- indexed(x=x)
indices(z)
indices(z[2:3])  # Indices are preserved

d <- indexed(
  data.frame(
    x=x,
    y=y
  )
)

indices(d)
indices(d[[1]])
indices(d$x)
indices(subset(d, y==1))
lapply(split(d, d$y), indices)

benjaminrich/table1 documentation built on June 10, 2025, 10:43 p.m.