Skip to content

subfolders in the R folder

2 messages · Antoine Fabri

#
Dear R-devel,

Packages don't allow for subfolders in R with a couple exceptions. We find
in "Writing R extensions" :
unix or windows.

This is something I've seen discussed outside of the mailing list numerous
times, and thanks to this SO question
https://stackoverflow.com/questions/14902199/using-source-subdirectories-within-r-packages-with-roxygen2
I could find a couple instances where this was discussed here as well,
apologies if I missed later discussions :

* https://stat.ethz.ch/pipermail/r-devel/2009-December/056022.html
* https://stat.ethz.ch/pipermail/r-devel/2010-February/056513.html

I don't see a very compelling conclusion, nor a justification for the
behavior, and I see that it makes some users snarky (second link is an
example), so let me make a case.

This limitation is an annoyance for bigger projects where we must choose
between having fewer files with too many objects defined (less structure,
more scrolling), or to have too many scripts, often with long prefixed
names to emulate essentially what folders would do. In my experience this
creates confusion, slows down the workflow, makes onboarding or open source
contributions on a new project harder (where do we start ?), makes dead
code easier to happen, makes it harder to test the rights things etc...

It would seem to me, but I might be naive, that it'd be a quick enough fix
to flatten the R folders not named "unix" or "windows"  when building the
package. Is there a good reason why we can't do that ?

Thanks,

Antoine

PS:
Other SO Q&As:
https://stackoverflow.com/questions/33776643/subdirectory-in-r-package
https://stackoverflow.com/questions/18584807/code-organisation-in-r-package-development
#
I just found this other discussion, with some more snark (who would have
thought this subject would be so slippery!) :
https://bugs.r-project.org/show_bug.cgi?id=17258

Duncan makes the argument that R's history shows the feature is not
absolutely necessary, but that's what make it a feature request and not a
bug report in my opinion. Feng makes the point that Python's history shows
that the feature is useful, and no counterpoint is made.