You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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):
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`#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>#> 1 numr_substitute(x, "fa") 18.9ms 21ms 45.2 NA 68.7bench::mark(
numr_replace(x, "fa")
)
#> # A tibble: 1 x 6#> expression min median `itr/sec` mem_alloc `gc/sec`#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>#> 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.
The text was updated successfully, but these errors were encountered:
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):But I do suspect
numr_substitute()
is more robust to e.g. character encoding and locale issues.The text was updated successfully, but these errors were encountered: