Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeated zeros truncated in added header row #239

Open
ddsjoberg opened this issue Mar 15, 2023 · 4 comments
Open

Repeated zeros truncated in added header row #239

ddsjoberg opened this issue Mar 15, 2023 · 4 comments

Comments

@ddsjoberg
Copy link

Hello!

I add a header row with the insert_row() function. When the header has repeated zeros, some are removed. In the example below, the header should read "**N = 1,000**", but is printing as **N = 1,0**.

Thank you 🍁

library(huxtable)
packageVersion("huxtable")
#> [1] ‘5.5.2’

hux <- 
  mtcars[1:3, 1] |>
  as_huxtable(add_colnames = FALSE) 

hux |> 
  insert_row(mpg = "**N = 1,000**")
#>                                       **N = 1,0**       
#>                                                   21    
#>                                                   21    
#>                                                   22.8  
#> 
#> Column names: V1

hux |> 
  insert_row(mpg = "**N = 1,234**")
#>                                       **N = 1,234**     
#>                                                   21    
#>                                                   21    
#>                                                   22.8  
#> 
#> Column names: V1
@hughjonesd
Copy link
Owner

Have you tried playing with number_format?

@hughjonesd
Copy link
Owner

My guess is that it's treating the numbers as separate and then number_format is truncating the zeros. This is a legit bug, I guess? but at the same time recognising what is a single number is very difficult and the regex we use is already hideous. I'm not sure that going further down this path will be helpful.

@ddsjoberg
Copy link
Author

Ohhh, I didn't realize huxtable was formatting numbers like this.

If I am not relying on huxtable to implement any formatting/rounding, do you recommend I add this to the end of all my series of huxtable calls? (I would add this internally in gtsummary)

ht |> 
  huxtable::set_number_format(NA)

@hughjonesd
Copy link
Owner

hughjonesd commented Mar 16, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants