2

I`m working in an existing program that uses a system of R6Class modules. An example function is stored in a file son.R and looks like:

#' @importFrom R6 R6Class
son_class <- R6Class("son", inherit = mother_class,
  private = list( ... Some private elements ... ),
  public = list(
     initialize = function(x, y, z) {
       ...Some code...
       super$initialize(x, y)
     },
     calculate = function(x,y,z) {
     ... More Code ...
     calc_son(x,y,z)
     }
  )
)

#' @inheritParams ...
#' @return ...
#' @template ...
#' @examples ...
#' @export
son  <- function(x = "son", y, z) {
        son_class$new(x, y, z)
}

The authors of the package say that the way to create new modules is by creating new R6Classes that inherit from mother_class. Thus I create a daughter.R file that looks almost the same, just change the son to daughter, but when I try to compile, I get the following error:

==> R CMD INSTALL --no-multiarch --with-keep.source mypackage

Error in .install_package_code_files ( , instdir " . " ) :
missing files in 'path / to / mypackage / R' in the' Collate ' : daughter.R
ERROR: unable to collate and parse R files for package ‘mypackage’

Which may be the source of this error. I am following the authors instruction verbatim.

John Gil
  • 51
  • 3
  • 8

1 Answers1

0

I got the way to do it (sort of). I include the NAMESPACE a line saying

export(daughter)

and in the DESCRIPTION file, after the

Collate: 
   'daughter.R'

After compiling the package everything seems OK and the function is fully integrated, except it lacks documentation. I am 100% sure that altering DESCRIPTION and NAMESPACE by hand is not standard practice and will created a follow up question regarding that:

Roxygen2: "Error in loadNamespace(name) : there is no package called ‘testthat’"?

Community
  • 1
  • 1
John Gil
  • 51
  • 3
  • 8