Skip to content

data set "not found" by roxygen2 #1733

@MichaelChirico

Description

@MichaelChirico

I think this is resurfacing #442.

I have a simple package:

.
├── data
│   └── mtcarsPkg.csv
├── DESCRIPTION
├── man
├── NAMESPACE
└── R
    └── data.R

4 directories, 4 files
# DESCRIPTION
Title: dataPkg
Package: dataPkg
Version: 0.1
RoxygenNote: 7.3.3
Encoding: UTF-8

# NAMESPACE is _empty_

# data/mtcarsPkg.csv is just write.csv(mtcars, "data/mtcarsPkg.csv")
# R/data.R
#' mtcars
"mtcarsPkg"

roxygenize() fails:

Error: 'mtcarsPkg' is not an exported object from 'namespace:dataPkg'

But R CMD INSTALL . works fine and the data is available:

R CMD INSTALL . && Rscript -e 'data("mtcarsPkg", package="dataPkg")' # (no error)

Based on #442 (comment), we might guess we just need to add LazyData: true, but that doesn't change anything.

We can fix it by using .rda instead, but some authors prefer using plaintext data and it's supported per WRE:

mtcarsPkg = mtcars
save(mtcarsPkg, file='data/mtcarsPkg.rda')
roxygenize() # works

At a minimum, we should document that only .rda is supported by roxygen2 in vignette("rd-other").

We can also "fix" this by doing mtcarsPkg <- NULL in R/data.R, and export(mtcarsPkg) in NAMESPACE, but that also confuses roxygenize():

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{mtcarsPkg}
\alias{mtcarsPkg}
\title{mtcars}
\format{
An object of class \code{NULL} of length 0.
}
\usage{
mtcarsPkg
}
\description{
mtcars
}
\keyword{datasets}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions