使用Roxygen2记录数据集

20

我正在尝试使用roxygen2在R包中记录一些数据集。只考虑其中一个:

  • 我有一个名为mypkg/data/CpG.human.GRCh37.RDa的对象
  • 其中包含一个名为CpG.human.GRCh37的对象
  • 和一个名为:mypkg/R/cpg-data.R的文件,其中包含:

  • #' @name CpG.human.GRCh37
    #' @title CpG islands - human - genome build: GRCh37/hg19
    #' @description This data set list the genomic locations of human CpG islands,
    #' with coordinates based on the GRCh37 / hg19 genome build.
    #' @docType data
    #' @usage CpG.human.GRCh37
    #' @format a \code{RangedData} instance, 1 row per CpG island.
    #' @source UCSC Table Browser
    #' @author Mark Cowley, 2012-03-05
    #' @export
    NULL
    
    当我使用Roxygen时,会生成 mypkg/man/CpG.human.GRCh37.Rd 文件,其中包含:
        \docType{data}
        \name{CpG.human.GRCh37}
        \alias{CpG.human.GRCh37}
        \title{CpG islands - human - genome build: GRCh37/hg19}
        \format{a \code{RangedData} instance, 1 row per CpG island.}
        \source{
          UCSC Table Browser
        }
        \description{
          This data set list the genomic locations of human CpG
          islands, with coordinates based on the GRCh37 / hg19
          genome build.
        }
        \author{
          Mark Cowley, 2012-03-05
        }
        \usage{CpG.human.GRCh37}
        \keyword{datasets}
    

    加入 export(CpG.human.GRCh37)NAMESPACE 文件中,但当我进行 R CMD CHECK 操作时,出现以下错误:

    ...
    ** testing if installed package can be loaded
    Error in namespaceExport(ns, exports) : 
      undefined exports: CpG.human.GRCh37
    Error: loading failed
    ...
    

    我没有告诉R去哪里找到这个数据集,尽管我认为 mypkg/data/<name>.RDa 应该是一个很好的第一猜测。任何提示都会很棒。

    如果Hadley在看,我注意到没有创建 \usage 部分,并且 @usage 指令被忽略了。

    我正在使用 roxygen-2.2.2,在 R 2.13.1 上。


4
我不确定 @export 指令是否用于数据集。建议尝试将其移除。 - Brandon Bertelsen
7
您不应该导出数据对象。 - Yihui Xie
3
谢谢大家。这需要进行两个修复:(1)根据《编写R扩展》1.5.1的要求,将对象保存为 .rda 格式(而不是 .RDa);(2)移除 @export。 - drmjc
2
@mjc 请将您的评论发布为答案,并标记为已回答以关闭此问题。 - Ari B. Friedman
2
@mjc,请发布一个答案并接受它,这样这个问题就不会显示为未回答。 - GSee
1个回答

17

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接