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

op-get-attr

Infix attribute accessor and setter


Description

This operator extracts or sets attributes for regular objects and S4 fields for S4 objects.

Usage

x %@% name

x %@% name <- value

Arguments

x

Object

name

Attribute name

value

New value for attribute name.

Examples

# Unlike `@`, this operator extracts attributes for any kind of
# objects:
factor(1:3) %@% "levels"
mtcars %@% class

mtcars %@% class <- NULL
mtcars

# It also works on S4 objects:
.Person <- setClass("Person", slots = c(name = "character", species = "character"))
fievel <- .Person(name = "Fievel", species = "mouse")
fievel %@% name

rlang

Functions for Base Types and Core R and 'Tidyverse' Features

v0.4.11
MIT + file LICENSE
Authors
Lionel Henry [aut, cre], Hadley Wickham [aut], mikefc [cph] (Hash implementation based on Mike's xxhashlite), Yann Collet [cph] (Author of the embedded xxHash library), RStudio [cph]
Initial release

We don't support your browser anymore

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