Open krzjoa opened 3 years ago
There is a some reason subdirectories are not allowed. The manual states that only special-purpose "unix/" and "windows/" subdirectories are allowed under R/ , presumedly for files that are specific to windows or unix systems.
Also, when discussing this matter, a well known R developer Hadley states here that he has no trouble managing big numbers of files in his packages.
A personal solution might be using directories while developing and then flattening them when building a package. This is also offered as a solution in the r-devel thread on the same topic.
Yes, I forgot to mention about the possible OS-related subdirectories. But still, it'd be not so hard to keep unix/ and windows/ subdirs reserved for the special purposes.
I know that there is no absolute measure to state that "there is to many/not so many files in this directory" and I stand by my opinion.
For me, there's little benefit (but also little harm) to allowing subdirectories if, at the end of the day, all the files are simply concatenated together - eg https://github.com/wch/r-source/blob/780021752eb83a71e2198019acf069ba8741103b/src/library/tools/R/admin.R#L299-L314
If, somehow, subdirectories could automatically be separately namespaced, the tools package itself would be a good candidate for refactoring - it currently uses a few nested, thousand-line closures to achieve some isolation, but that can make it hard to debug or figure out what it's actually doing.
From my perspective, as the multiple files are better than one big file, so are multiple subdirectories better than one big directory. It would really make difference.
Sub-namespaces is another interesting topic. I didn't write about it because for now I have no idea, how should it be implemented.
@krzjoa the package box provides modules and sub-modules. The barrier to start a module is much lower than to start a package, but it lacks the versioning and distribution mechanisms of R packages
I know the box
package, but the goal of this proposal is to organize scripts in packages rather than create submodules.
When creating a new R package, there is no possibility to organize the scripts in categorical subfolders. I guess there was an assumption that every R package should be modular and atomic, so it'll never be bigger than just a couple of scripts.
However, projects such as e.g.
torch
orparsnip
show that without subdirectories it can get a little bit messy. In thesrc
folder, unlike theR
directory, it's possible to use subfolders (see an example: rcpp-headers-subdirs).In my opinion, it would make package development more convenient in many cases.