Learn R Programming

DescTools (version 0.99.40)

StripAttr: Remove Attributes from an Object

Description

For convenience we sometimes want to strip some or all attributes in a oneliner.

Usage

StripAttr(x, attr_names = NULL)

Arguments

x

the object whose attributes should be removed.

attr_names

a vector with attribute names, which will be removed. Leaving the default to NULL will cause all the attributes to be deleted.

Value

the object x without the attributes contained in attr_names

See Also

SetNames, unname

Examples

Run this code
# NOT RUN {
x <- runif(10)
attr(x, "some_attr") <- "First attribute"
attr(x, "other_attr") <- "Second attribute"

# strip all attributes
StripAttr(x)

# only some
StripAttr(x, "other_attr")
# }

Run the code above in your browser using DataLab