pharmaverse / pharmaverse/formatters
`data_precision_fmt` for precision based format
Open
Nobody has claimed this yet.
enhancement
sme
- Dominant language
- R
- Stars
- 20
- Forks
- 8
- Avg merge
- 12h 28m
- Merged PRs (30d)
- 1
Description
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
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue provides no file or test path; begin by locating the formatter entry points and the proposed data_precision_digs, data_precision_fmt, and digs_to_fmt functions. Confirm the precision rules with maintainers, then add tests covering finite-precision inputs and verify that the resulting format adds the requested digit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100