numr_replace() or numr_substitute()?
- Dominant language
- R
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Which to use as the default for formatting numerals? `numr_replace()` uses string replacement; `numr_substitute()` decomposes a numeric into digits and directly subsets the numerals matrix.
I was hoping `numr_substitute()` would be faster, but it isn't (yet):
``` r
library("numerals")
x <- floor(runif(1000) * 1e6)
bench::mark(
numr_substitute(x, "fa")
)
#> Warning: Some expressions had a GC in every iteration; so filtering is disabled.
#> # A tibble: 1 x 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#>
#> 1 numr_substitute(x, "fa") 18.9ms 21ms 45.2 NA 68.7
bench::mark(
numr_replace(x, "fa")
)
#> # A tibble: 1 x 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#>
#> 1 numr_replace(x, "fa") 8.51ms 8.54ms 112. NA 0
```
But I do suspect `numr_substitute()` is more robust to e.g. character encoding and locale issues.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.