【发布时间】:2017-07-20 18:11:43
【问题描述】:
我在使用 devtool 的 build() 和 check() 函数构建 R 包时遇到了许多问题。最严重的是这些函数在R目录下的.R文件中找不到用setClass创建的类定义。
例如,以下代码包含在 R\rnet.input.R 中,并定义了一个对象,该对象包含从它继承的更涉及的类的各种插槽。
#' 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'
)
)
但是,在 build() 和 check() 期间,由于以下错误,该过程失败:
Error in reconcilePropertiesAndPrototype(name, slots, prototype, superClasses, :no definition was found for superclass “rnet.input” in the specification of class “rnet.basic”
我尝试将 .R 文件放置在多个位置定义这些类的位置。唯一发生变化的情况是当我在一个文件中拥有所有 5 个定义时,此时检查将运行,但仍声称它们在某些时候未定义并且存在“sodoc”冲突。我也尝试过添加名称、rdname、export 和 exportClass 标签,但这并没有解决任何问题。
其他问题包括 check() 声称具有文档的数据集未记录,并且其他数据集在多个位置创建,即使对这些对象的代码引用仅在单个文件中出现一次。
感谢任何帮助。
【问题讨论】:
-
这是我们可以 fork 的 GitHub 上的仓库吗?
-
是的,谢谢,我打算包括在内。它可用here。我认为我用来构建包的代码也在那里。如果不是,我会添加它。我对使用 github 也很陌生,如果存储库一团糟,敬请见谅。
标签: r devtools roxygen2 r-package