R: use your own file / directory structure in the pkg / R and pkg / src folders.

I am writing an R package that is starting to grow in size, and therefore it would be very useful to use a custom structure in the pkg / R / folders and (especially) in pkg / src /.

For example, suppose I have two families of algorithms of some type A and some functions of type B and the main entry point. Ideally, R / or src / folders will be organized as follows:

  • TypeA /
    • algorithms1 /
      • algo11.ext
      • ...
    • algorithms2 /
      • algo21.ext
      • ...
  • TypeB /
    • function1.ext
    • ...
  • main.ext

with "ext" in {R, cpp, c, f, ...} and potentially two files with the same name.

Is it possible? If so, how can I do this?

Thanks in advance!


[2012-12-31] EDIT: the idea would be to write several scripts - perhaps inside another R package - to (un) smooth out a structured package for tests or distribution. But probably the best solution, so I'll wait a bit.

+6
source share
1 answer

As a pointer to "Writing R-Extensions" here , the Makevars file in pkg / src allows you to have subfolders for C / C ++ / Fortran code. (See, for example, RSiena package.)

However, I did not find anything regarding the custom structure in pkg / R. Therefore, I wrote a small package (you can use it, although it needs improvements), which performs the following tasks:

  • Download / unload a package that has (potentially) subfolders under pkg / R
  • Run R and / or C-unit tests on it [basic structure to be replaced (for example, RUnit and verification)]
  • Export a package that should be compatible with CRAN (smooth R-code, generate Makevars file)

I will link it here if it reaches the published state. (At the moment I can send it by email).

+1
source

All Articles