SebKrantz / collapse

Advanced and Fast Data Transformation in R
https://sebkrantz.github.io/collapse/
Other
627 stars 33 forks source link

Increasing maximum number of table elements to print for categorical variables in descr() gives error #607

Closed wachtermh closed 3 weeks ago

wachtermh commented 3 weeks ago

Hi,

When increasing the maximum number of table elements to print for categorical variables in descr():

library(collapse)
data(iris)
descr(iris$Species, n = 10)

it gives the following error: Error in x[[2L]] : subscript out of bounds

I used the iris dataset just as an example. I noticed it on another dataset with a variable with many categories.

> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.5

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Berlin
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] collapse_2.0.14

loaded via a namespace (and not attached):
 [1] zoo_1.8-12          compiler_4.4.1      parallel_4.4.1      sandwich_3.1-0      tools_4.4.1         rstudioapi_0.16.0  
 [7] dreamerr_1.4.0      Rcpp_1.0.12         fixest_0.12.1       nlme_3.1-165        grid_4.4.1          Formula_1.2-5      
[13] numDeriv_2016.8-1.1 stringmagic_1.1.2   renv_1.0.7          lattice_0.22-6 
SebKrantz commented 3 weeks ago

You need to pass it to print, not to descr(): print(descr(iris$Species), n = 10)

wachtermh commented 3 weeks ago

Ohhh, I overlooked that in the documentation. Thank you!