Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fields

Tools for accessing the fields of a record.


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

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

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

Vector Helpers

v0.3.8
MIT + file LICENSE
Authors
Hadley Wickham [aut], Lionel Henry [aut, cre], Davis Vaughan [aut], data.table team [cph] (Radix sort based on data.table's forder() and their contribution to R's order()), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.