Learn R Programming

utilities (version 0.4.0)

rm.attr: Remove (non-protected) attributes from an object

Description

rm.attr removes (non-protected) attributes from an object

Usage

rm.attr(
  object,
  list.levels = Inf,
  protected = c("class", "dim", "names", "dimnames", "rownames", "colnames")
)

Arguments

object

An object to operate on attributes from the object

list.levels

A non-negative integer specifying the number of levels of lists to apply the removal to

protected

A character vector containing the names of protected attributes (not to be removed)

Value

The object is returned with non-protected attributes removed

Details

This function removes non-protected attributes from an R object. If the object is a list then the function will remove attributes within elements of the list down to the level specified by the list.levels input. (By default the function removes attributes from all levels of lists.) If you do not want to remove attributes from elements of a list (but still remove attributes from the outer level) you can set list.levels = 0 to do this..

Examples

Run this code
# NOT RUN {
a <- structure(list(structure(1, x=2, names=3),
               list(0, structure(3, x=4, names=5))),
               x=3, names = 4)
str(rm.attr(a, 1))

# }

Run the code above in your browser using DataLab