summarytools icon indicating copy to clipboard operation
summarytools copied to clipboard

fix: invalid value 0 for 'digits' argument

Open mcanouil opened this issue 2 years ago • 0 comments

Since R 4.2.0, digits arguments of format() is constrained to be higher or equal to 1. nsmallset to zero should be enough to get the requested "integer" format.

This PR, ensures digits is at least 1 in print_ctable().

fixes #163

  • master branch (current behaviour)

    data("tobacco")
    ctable(tobacco$gender, tobacco$smoker, round.digits = 0)
    #> Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L,  : 
    #>  invalid value 0 for 'digits' argument
    
  • PR

    data("tobacco")
    ctable(tobacco$gender, tobacco$smoker, round.digits = 0)
    #> Cross-Tabulation, Row Proportions  
    #> gender * smoker  
    #> Data Frame: tobacco  
    #> 
    #> -------- -------- ----------- ----------- -------------
    #>            smoker         Yes          No         Total
    #>   gender                                               
    #>        F            147 (30%)   342 (70%)    489 (100%)
    #>        M            143 (29%)   346 (71%)    489 (100%)
    #>     <NA>              8 (36%)    14 (64%)     22 (100%)
    #>    Total            298 (30%)   702 (70%)   1000 (100%)
    #> -------- -------- ----------- ----------- -------------------
    

mcanouil avatar May 07 '22 02:05 mcanouil