Get rid of summarytools-specific attributes to get a simple data structure (matrix, array, ...), which can be easily manipulated.
zap_attr(x, except = c("dim", "dimnames"))
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()
.
data(tobacco)
zap_attr(descr(tobacco))
#> BMI age cigs.per.day samp.wgts
#> Mean 2.573082e+01 49.60205128 6.782383e+00 1.000000e+00
#> Std.Dev 4.488068e+00 18.28918947 1.187654e+01 8.387755e-02
#> Min 8.825777e+00 18.00000000 0.000000e+00 8.614232e-01
#> Q1 2.292600e+01 34.00000000 0.000000e+00 8.614232e-01
#> Median 2.561962e+01 50.00000000 0.000000e+00 1.044177e+00
#> Q3 2.865065e+01 66.00000000 1.100000e+01 1.049383e+00
#> Max 3.943901e+01 80.00000000 4.000000e+01 1.062500e+00
#> MAD 4.175650e+00 23.72160000 0.000000e+00 7.718429e-03
#> IQR 5.721849e+00 32.00000000 1.100000e+01 1.879595e-01
#> CV 1.744238e-01 0.36871841 1.751086e+00 8.387755e-02
#> Skewness 1.673769e-02 -0.04027808 1.536599e+00 -1.035360e+00
#> SE.Skewness 7.836620e-02 0.07832613 7.872967e-02 7.734382e-02
#> Kurtosis 2.550406e-01 -1.25924962 9.036813e-01 -9.033348e-01
#> N.Valid 9.740000e+02 975.00000000 9.650000e+02 1.000000e+03
#> N 1.000000e+03 1000.00000000 1.000000e+03 1.000000e+03
#> Pct.Valid 9.740000e+01 97.50000000 9.650000e+01 1.000000e+02
zap_attr(freq(tobacco$gender))
#> Freq % Valid % Valid Cum. % Total % Total Cum.
#> F 489 50 50 48.9 48.9
#> M 489 50 100 48.9 97.8
#> <NA> 22 NA NA 2.2 100.0
#> Total 1000 100 100 100.0 100.0