Movatterモバイル変換


[0]ホーム

URL:


rdrr.io

attr: Object Attributes

attrR Documentation

Object Attributes

Description

Get or set specific attributes of an object.

Usage

attr(x, which, exact = FALSE)attr(x, which) <- value

Arguments

x

an object whose attributes are to be accessed.

which

a non-empty character string specifying which attributeis to be accessed.

exact

logical: shouldwhich be matched exactly?

value

an object, the new value of the attribute, orNULLto remove the attribute.

Details

These functions provide access to a single attribute of an object.The replacement form causes the named attribute to take the valuespecified (or create a new attribute with the value given).

The extraction function first looks for an exact match towhichamongst the attributes ofx, then (unlessexact = TRUE)a unique partial match.(Settingoptions(warnPartialMatchAttr = TRUE) causespartial matches to give warnings.)

The replacement function only uses exact matches.

Note that some attributes (namelyclass,comment,dim,dimnames,names,row.names andtsp) are treated specially and have restrictions onthe values which can be set. (Note that this is not true oflevels which should be set for factors via thelevels replacement function.)

The extractor function allows (and does not match) empty and missingvalues ofwhich: the replacement function does not.

NULL objects cannot have attributes and attempting toassign one byattr gives an error.

Both are primitive functions.

Value

For the extractor, the value of the attribute matched, orNULLif no exact match is found and no or more than one partial match is found.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language.Wadsworth & Brooks/Cole.

See Also

attributes

Examples

# create a 2 by 5 matrixx <- 1:10attr(x,"dim") <- c(2, 5)

What can we improve?

R Package Documentation

Browse R Packages

We want your feedback!

Note that we can't provide technical support on individual packages. You should contact the package authors for that.

 
Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, readEmbedding Snippets.

Close

[8]ページ先頭

©2009-2026 Movatter.jp