Linking multiple files while creating a package in R
As far as I understand, you can use the Collate
field in the DESCRIPTION
file to control this.
Quoting from the Writing R Extensions manual:
An ‘Collate’ field can be used for controlling the collation order for the R code files in a package when these are processed for package installation. The default is to collate according to the ‘C’ locale. If present, the collate specification must list all R code files in the package (taking possible OS-specific subdirectories into account, see Package subdirectories) as a whitespace separated list of file paths relative to the R subdirectory. Paths containing white space or quotes need to be quoted. An OS-specific collation field (‘Collate.unix’ or ‘Collate.windows’) will be used instead of ‘Collate’.
So, you could specify:
Collate: father.r son.R grandson.r
Or simply rename the files in such a way that lexicographic sorting order will result in the correct collation order, as you indicated in your question.
But also see this answer by @DirkEddelbuettel on a similar question.