[Rd] subfolders in the R folder

Antoine Fabri @nto|ne@|@br| @end|ng |rom gm@||@com
Tue Mar 28 17:42:52 CEST 2023


Dear R-devel,

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

> The R and man subdirectories may contain OS-specific subdirectories named
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

	[[alternative HTML version deleted]]



More information about the R-devel mailing list