Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

documenting dataset with roxygen2

Tags:

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

like image 952
drmjc Avatar asked Mar 05 '12 04:03

drmjc


People also ask

How do you write ROxygen2?

The Roxygen2 comments are just R comments (preceded by # ), but you need to use #' to distinguish the Roxygen2 comments from any normal R comments. And it has things like @param rather than \item{} . There are still a few of .

How do I load data into an R package?

The default R datasets included in the base R distribution Simply check the checkbox next to the package name to load the package and gain access to the datasets. You can also click on the package name and RStudio will open a help file describing the datasets in this package.


1 Answers

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
like image 156
Andrie Avatar answered Apr 20 '23 06:04

Andrie