zap_attr: Remove Attributes to Get a Simplified Object

View source: R/helpers.R

zap_attrR Documentation

Remove Attributes to Get a Simplified Object

Description

Get rid of summarytools-specific attributes to get a simple data structure (matrix, array, ...), which can be easily manipulated.

Usage

zap_attr(x, except = c("dim", "dimnames"))

Arguments

x

An object with attributes

except

Character. A vector of attribute names to preserve. By default, “dim” and “dimnames” are preserved.

Details

If the object contains grouped results:

  • The inner objects will lose their attributes

  • The “stby” class will be replaced with “by”

  • The “dim” and “dimnames” attributes will be set to available relevant values, but expect slight differences between objects created with stby() vs group_by().

Examples

data(tobacco)
zap_attr(descr(tobacco))
zap_attr(freq(tobacco$gender))

dcomtois/summarytools documentation built on March 1, 2025, 8:50 p.m.