Skip to content

Add function for 3 sig figures to fix the issue in gtsummary::label_style_sigfig(3) #287

Description

@qiliu1013

Feature description

In gtsummary::label_style_sigfig(3) for any number < 0.1 — it assumes 3 decimal places
is enough, this is not correct. 0.037 needs 4 decimal places for 3 sig figs
(0.0370), and 0.0037 would need 5.

The function to keep 3 sig figures should be
fmt_3sig <- function(x) { if (is.na(x) || !is.finite(x)) return(NA_character_) gsub("\\.$", "", formatC(signif(x, 3), digits = 3, format = "fg", flag = "#")) }

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions