R CMD检查不识别S3泛型方法

时间:2018-02-01 19:20:54

标签: r r-package r-s3

我正在编写一个包,如果我在我的Rstudio中运行它运行但是当我将它提供给R CMD检查运行时,它无法识别S3方法。 我有一个通用的方法:

count_kmers <- function(obj, klen = 6, parallel = TRUE, 
                    nproc = ifelse(parallel, comm.size(), 1), 
                    distributed = FALSE) {
                          UseMethod("count_kmers", obj)
                }

然后是替代方法:

count_kmers.character <- function(obj, klen = 6, parallel = TRUE, 
                              nproc = ifelse(parallel, comm.size(), 1), 
                              distributed = FALSE) {...}
count_kmers.AAStringSet <- function(obj, klen = 6, parallel = TRUE, 
                                nproc = ifelse(parallel, comm.size(), 1), 
                                distributed = FALSE){...}

现在我在我的文档中运行的一个例子是:

seqs <- AAStringSet(c("seq1"="MLVVD",
                  "seq2"="PVVRA",
                  "seq3"="LVVR"))
## Count the kmers and generate a dataframe of the frequencies
freqs <- count_kmers(seqs, klen = 3, parallel = FALSE)
head(freqs)

如果我将代码作为普通代码运行它可以工作,但如果我使用R CMD检查它,那么它会抱怨:

Error in UseMethod("count_kmers", obj) : 
no applicable method for 'count_kmers' applied to an object of class "c('AAStringSet', 'XStringSet', 'XRawList', 'XVectorList', 'List', 'Vector', 'list_OR_List', 'Annotated')"

AAStringSet是Biostrings包中的一个对象。但这没关系,即使我将一个字符串传递给count_kmers,我收到同样的错误,但是说:

no applicable method for 'count_kmers' applied to an object of class "character".

0 个答案:

没有答案