R beginner with a two part question –
-
I like the one class per file ‘rule’ in ‘other’ languages – is this a common practise in R also ?
-
How would I go about doing this in R ? From the documentation I’ve read so far, I would have to create a package and use ‘require’. However, will I need to write man pages and documentation for each package ? (One file may contain a very small class that I don’t really want to document). Are there any alternative ways of doing this ?
Many thanks
Three options for you:
ProjectTemplate may have functionality that would let you load all source scripts in a given directory automatically.
You can write a simple script that does it yourself by
source()ing the output ofdir().taRifx::readdirdoes something similar to load all data files in a directory.Likely the best answer: put all your functions into a package, even if you don’t release it to CRAN. All .R files in the R directory automatically become part of the package when you build it. Bonus: documentation becomes easier as well (use
roxygen2).