Gets and Sets an Attribute of an R Object

getAttrib(vec, name)

setAttrib(vec, name, val)

Source

Declaration: src/include/Rinternals.h

Implementation: src/main/attrib.c

Arguments

vec

(SEXP) An R object.

name

(SEXP) A character of length one.

val

(SEXP) An R object.

Value

getAttrib() returns (SEXP) the value of attribute name.

setAttrib() returns (SEXP) a copy of R object vec with attribute name set.

(SEXP)

C API

#include <Rinternals.h>

SEXP getAttrib(SEXP vec, SEXP name)
SEXP setAttrib(SEXP vec, SEXP name, SEXP val)

R API

library(base)

value <- attr(vec, name, exact = TRUE)
attr(vec, name) <- val