Will L
Will L

Reputation: 43

Roxygen2 unable to find class definition during build & check

I'm having a number of problems building an R package using devtool's build() and check() functions. The most severe one is that the these functions do not find class definitions created with setClass in .R files in the R directory.

For example, the following code is contained in R\rnet.input.R and defines an object containing the various slots for a more involved class that inherits from it.

#' rnet.input - An S4 class for accepting input data common for generating all rnet objects. These objects are used to handle rnet objects and need not be called by the user.
#' 
#' The superclass for holding input for rnet functions.
#' 
#' @slot RawData A dataframe containing the original dataset.
#' @slot cor_method The type of correlation matrix to use. Must be a partial match to one of the following strings: 'pearson', 'spearman', 'kendall'.
#' @slot cor_pairing Method for handling how missing data is handled in pairs. See 'pair' argument in function 'cor' for more information.
#' @slot n_threshold The minimum number of valid pair-wise observations that must exist for an edge to be estimated. Vertex pairs with fewer valid pair-wise observations are assumed to be conditiontally independent.
#' @slot L1_orig The declared L1 penalty to be used when estimating rnet topology
#' @slot v_set_orig The declared set of k variables to be included in the rnet as vertices
#' @slot Forced_zeros A matrix with 2 columns containing pairs of vertices to force to be conditionally independent in the rnet
#' @slot Layout_master A k x 2 matrix x & y coordinates of each vertex in the graph.

rnet.input <- setClass(Class = "rnet.input",
                   slots = list(
                     RawData = 'data.frame',
                     cor_method = 'character',
                     cor_pairing = 'character',
                     n_threshold = 'numeric',
                     L1_orig = 'numeric',
                     V_set_orig = 'character',
                     Forced_zeros = 'matrix',
                     Layout_master = 'ANY'
                   )
)

However, during build() and check(), the process fails due to the following error:

Error in reconcilePropertiesAndPrototype(name, slots, prototype, superClasses,  :no definition was found for superclass “rnet.input” in the specification of class “rnet.basic”

I have tried placing the .R files where these classes are defined in multiple locations. The only time something changes is when I have all 5 definitions in one file, at which point the check will run but still claims they are not defined at some points and that there are 'sodoc' conflicts. I have also tried adding the name, rdname, export, and exportClass tags, but this has not solved anything.

Other problems include check() claiming datasets that have documentation are undocumented and other datasets are created in more than one place, even though code references to those objects only appear once a single file.

Any help is appreciated.

Upvotes: 3

Views: 722

Answers (1)

F. Priv&#233;
F. Priv&#233;

Reputation: 11728

Okay that was easy.

You need to add #' @include Rnet_classes.R, for example in the documentation of setGeneric('Assign_Emetadata' so that roxygen2 knows that it should be rendered before.

This will add a Collate: field in your DESCRIPTION file.

Upvotes: 3

Related Questions