I am writing a package for R in which the exported functions are decorated with a higher order function that adds error checking and some other boilerplate code.
However, since this code is at the top level, it is evaluated after parsing. This means that you need to download package files.
To give an equivalent but simplified example, suppose I have a package with two files (Negate2 and Utils), and I require Negate2.R to be loaded first for the isfalse () function, which should be determined without throwing an error.
# /Negate2.R Negate2 <- Negate
Is it possible to structure NAMESPACE, DESCRIPTION (collate) or another package file to change the file upload order? The inner workings of the R and CRAN package structure are still black magic for me.
You can work around this problem using inconvenient hacks, but the least repetitive way to solve this problem. The wrapper function must be a higher-order function, since it also changes the semantics of the function call of the input function. The code package is heavy (~ 6000 lines, 100 functions), so repetition will be ... problematic.
Decision
As @Manetheran points out, to change the order of loading, you simply reorder the file names in the DESCRIPTION file.
# /DESCRIPTION Collate: 'Negate2.R' 'Utils.R'
r build package
Ryan grannell
source share