build - Changing the load order of files in an R package -


i'm writing package r in exported functions decorated higher-order function adds error checking , other boilerplate code.

however, because code @ top-level evaluated after parsing. these means load order of package files important.

to give equivalent simplified example, suppose have package 2 files (negate2 , utils), , require negate2.r loaded first function 'isfalse( )' defined without throwing error.

# /negate2.r negate2 <- negate  # -------------------  # /utils.r istrue <- istrue isfalse <- negate2(istrue) 

is possible structure namespace, description (collate) or package file in order change load order of files? internal working of r package structure , cran still black magic me.

it possible around problem using awkward hacks, least repetitive way of solving problem. wrapper function must higher-order function, since changes function call semantics of input function. package code heavy (~6000 lines, 100 functions) repetition be...problematic.

solution

as @manetheran points out, change load order change order of file names in description file.

# /description collate:     'negate2.r'     'utils.r' 

the collate: field of description file allows change order files loaded when package built.

i stumbled across answer question yesterday while reading on roxygen. if you've been documenting functions roxygen, can try intelligently order r source files in collate: field (based on s4 class , method definitions are). can done adding "collate" roclets argument of roxygenize. alternatively if you're developing in rstudio there simple box can checked under build->configure build tools->configure... (button next "generate documentation roxygen").


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -