HenrikBengtsson / matrixStats

R package: Methods that Apply to Rows and Columns of Matrices (and to Vectors)
https://cran.r-project.org/package=matrixStats
203 stars 33 forks source link

CLEANUP: R environment variables only parsed during package load #252

Closed HenrikBengtsson closed 6 months ago

HenrikBengtsson commented 6 months ago

Following the Futureverse strategy, we should move to:

  1. Only read and parse environment variables R_MATRIXSTATS_NNN during .onLoad()

  2. These R env vars will set corresponding matrixStats.nnn R options

  3. Only the R options will be used in the code

This will:

  1. Clarify when env vars are used and when they can be set, i.e. before loading the package, probably before launching R
  2. Lower overhead, because env vars only have to be queried once. If parsing is involved, that will also only be done once, e.g. validating, parsing, coercing an integer or a float.
HenrikBengtsson commented 6 months ago

It is already the case that environment variables are read and parsed during package startup. Either way, I'll tidy up the code and borrow from Futureverse to simplify this.

HenrikBengtsson commented 6 months ago

Done. All options and env vars are now set in https://github.com/HenrikBengtsson/matrixStats/blob/develop/R/options.R, which also documents them. This should make it easier when we changing existing defaults, introducing new options/env vars, etc.