rhuxtable

How to change digits of numbers in the export_summs() table


I get the regression output table using export-summs() installed in the package called jtools and huxtable.

My code is: export_summs(model1, model2, scale = TRUE) and

          ────────────────────────────────────────────────────
                                Model 1          Model 2      
                           ───────────────────────────────────
            (Intercept)            0.28 **          0.00      
                                  (0.10)           (0.02)     
            educ                   0.09 ***                   
                                  (0.01)                      
            exper                  0.00 *                     
                                  (0.00)                      
            tenure                 0.02 ***                   
                                  (0.00)                      
            xtilde                                  0.09 ***  
                                                   (0.01)     
                           ───────────────────────────────────
            N                    526              526         
            R2                     0.32             0.23      
          ────────────────────────────────────────────────────
            *** p < 0.001; ** p < 0.01; * p < 0.05.           

Is there any way to make all the digits 3 decimal numbers?


Solution

  • You can pass a number_format string directly:

    library(jtools)
    
    model1 <- lm(drat ~ wt + hp, mtcars)
    model2 <- lm(drat ~ hp, mtcars)
    
    export_summs(model1, model2, scale = TRUE, number_format = "%.4g")
    #> ----------------------------------------------------------------------------
    #>                                   Model 1                  Model 2          
    #>                          ---------------------------------------------------
    #>   (Intercept)                          3.597 ***                 3.597 ***  
    #>                                       (0.06852)                 (0.08586)   
    #>   wt                                  -0.3937 ***                           
    #>                                       (0.09254)                             
    #>   hp                                   0.01942                  -0.2399 **  
    #>                                       (0.09254)                 (0.08724)   
    #>                          ---------------------------------------------------
    #>   N                                   32                        32          
    #>   R2                                   0.5083                    0.2014     
    #> ----------------------------------------------------------------------------
    #>   All continuous predictors are mean-centered and scaled by 1               
    #>   standard deviation.  *** p < 0.001; ** p < 0.01; * p < 0.05.              
    #> 
    #> Column names: names, Model 1, Model 2