epiverse-trace / numberize

Convert words to numbers in English, French and Spanish
https://epiverse-trace.github.io/numberize/
Other
4 stars 2 forks source link

Use "native" vectorisation #11

Open Bisaloo opened 5 months ago

Bisaloo commented 5 months ago

Opening this issue as a reminder of the discussion started in https://github.com/epiverse-trace/numberize/pull/6#discussion_r1532548560.

Most R functions are vectorized by default (using loops in C) so it may be much more efficient to rely on this rather than a vapply() loop.

bahadzie commented 4 months ago

You are right that most of the functions I was using were already vectorized.

The only one I had an issue with was match() in numberize.R. It didn't natively vectorize it as I expected and it might be an issue in my understanding of how it works. The only way I got it to work was to use apply() which felt like kicking the can down the road. That's why I didn't fully vectorize it natively.

After the CRAN release, I will see if I can come up with a solution for it.

Bisaloo commented 11 hours ago

Partially fixed by #15