documenting dataset with roxygen2
Asked Answered
S

1

20

I'm trying to document some datasets in an R package using roxygen2. Considering just one of these:

  • I have mypkg/data/CpG.human.GRCh37.RDa
  • which contains an object called CpG.human.GRCh37
  • and a file called: mypkg/R/cpg-data.R, which contains:

    #' @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
    

When I roxygenize, this gets created mypkg/man/CpG.human.GRCh37.Rd, containing:

    \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}

and export(CpG.human.GRCh37) gets added the NAMESPACE file.

but when I R CMD CHECK I get:

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

Nowhere have I told R where to find this dataset, though I would assume that the mypkg/data/<name>.RDa would be a good first guess. Any hints would be awesome.

If Hadley's watching, I notice that an \usage section is not created and the @usage directive is ignored.

i'm using roxygen-2.2.2, on R 2.13.1

Supremacist answered 5/3, 2012 at 4:35 Comment(5)
I'm not sure that the @export directive is used for data sets. Try removing this.Titular
you should not export the data objectOswin
thanks guys. this required 2 fixes (1) as per Writing R extensions 1.5.1, save the objects as .rda (not .RDa); and (2) remove the @exportSupremacist
@mjc Kindly post your comment as an answer and mark it answered to close off this question.Feucht
@mjc, please post an answer and accept it so that this question does not show up an unanswered.Payroll
I
17

This required 2 fixes:

  1. As explained in Writing R extensions 1.1.5, Data in packages, save the objects as .rda instead of .RDa
  2. remove @export from the Roxygen
Iritis answered 18/10, 2012 at 10:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.