dcomtois / summarytools

R Package to Quickly and Neatly Summarize Data
523 stars 78 forks source link

prettyNum error #178

Closed ecamburn closed 1 year ago

ecamburn commented 2 years ago

Love summarytools but I'm getting the following error when using ctable:

Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, : invalid value 0 for 'digits' argument

Here's the line that generates the error. It's worked without problem in the past. I recently updated R (4.2.2) and RStudio (2022.07.2 Build 576). subject and eng are ordinal variables

ctable(tsubject$subject,tsubject$eng)

jttoivon commented 1 year ago

I'm having the same issue. The following code doesn't work: ctable(c("a","b"), 1:2) but the following does work: ctable(c("a","b"), as.factor(1:2)) According to the help page, ctable should also accept numeric input.

This is probably due to change in R 4.2.0:

Setting digits = 0 in format(), print.default() (and hence typically print()) or options() is again invalid. Its behaviour was platform-dependent, and it is unclear what “zero significant digits” should mean (PR#18098).

https://cran.r-project.org/doc/manuals/r-devel/NEWS.html

Jarkko

jttoivon commented 1 year ago

A fix for this has been available already for a long time. Install the package from GitHub, if you want the fix. Hopefully version 1.0.2 of the package, containing the fix, will be released soon.

ecamburn commented 1 year ago

Thanks @jttoivon

Installing from github fixed it here. For anyone else who runs into this, updating rlang was necessary when updating summarytools