fields: Tools for accessing the fields of a record.

Description Usage Arguments Examples

View source: R/fields.R

Description

A rcrd behaves like a vector, so length(), names(), and $ can not provide access to the fields of the underlying list. These helpers do: fields() is equivalent to names(); n_fields() is equivalent to length(); field() is equivalent to $.

Usage

1
2
3
4
5
6
7
fields(x)

n_fields(x)

field(x, i)

field(x, i) <- value

Arguments

x

A rcrd, i.e. a list of equal length vectors with unique names.

Examples

1
2
3
4
5
6
7
x <- new_rcrd(list(x = 1:3, y = 3:1, z = letters[1:3]))
n_fields(x)
fields(x)

field(x, "y")
field(x, "y") <- runif(3)
field(x, "y")

vctrs documentation built on April 29, 2021, 5:08 p.m.