0

I want to submit an R package to CRAN. All packages that I know have a separate .R or .cpp file for each of their .R or .cpp functions, respectively. Is this a necessary property for a package to be accepted by CRAN?

1 Answers1

2

No.

You could have all your R code in one file R/myfile.R and all your C++ code in src/myfile.cpp. But files are "transient" anyway in the sense that R now bytecompiles all R code into another internal representation, and of course always compiled native source code in C, C++, Fortran, ... as needed into object code that is loaded dynamically as needed.

You have to pass R CMD check --as-cran and adhere to the CRAN Repo Policy otherwise but there is no restriction that each function needs a source file -- entirely up to you to organise as you see fit.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725