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

data_precision_fmt for precision based format #43

Open
gmbecker opened this issue Aug 31, 2022 · 1 comment
Open

data_precision_fmt for precision based format #43

gmbecker opened this issue Aug 31, 2022 · 1 comment
Labels
enhancement New feature or request sme Tracks changes for the sme board

Comments

@gmbecker
Copy link
Collaborator

gmbecker commented Aug 31, 2022

E.g., mean(x) should have 1 decimal points more effective precision than x did (only really makes sense when x was measured to finite, relatively low precision)

Very rough, probably wrong mockup of behavior

data_precision_digs <- function(x, digits_more= 1) {
  stopifnot(is.numeric(x)) 
  chr <- as.character(x)
  chr <- gsub("e[-+][0-9]$", "", chr)
  ## leading zeros (without a .) and trailing zeros (ever) are not precision
  chr <- gsub("[0]*([.123456789][[:digit:].]*[123456789])[0.]*$", "\\1", chr) 
  chr <- gsub(".", "", chr, fixed = TRUE)
  max(nchar(chr)) + digits_more
}

data_precision_fmt <- function(x, digs_more = 1) {
   digs <- data_precision_digs(x, digs_more)
   digs_to_fmt(digs)
}

digs_to_fmt <- function(digs) {
## awesome code goes here
}
@gmbecker gmbecker added the enhancement New feature or request label Aug 31, 2022
@shajoezhu shajoezhu added the sme Tracks changes for the sme board label Nov 9, 2022
@edelarua
Copy link
Contributor

Feature implemented in tern: insightsengineering/tern#1051

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sme Tracks changes for the sme board
Projects
None yet
Development

No branches or pull requests

3 participants