I am building an R package that includes several datasets. I have the datasets saved as .RData objects in my "data" folder, and each dataset has documentation generated using roxygen2
. When I install the package, load it and try to call a dataset,
devtools::install_github("jamesmartherus/nhldata")
library(nhldata)
data(teams)
I get this error:
In data("teams") : data set ‘teams’ not found
Here is the content of my DESCRIPTION file:
Package: nhldata
Title: Easy Access to Basic NHL Data
Version: 0.1.0
Authors@R: person("James", "Martherus", email = "james@martherus.com",
role = c("aut", "cre"))
Description: Includes several datasets of NHL statistics including skater, goalie, and team statistics by season.
Depends: R (>= 3.5.0)
License: MIT
LazyData: true
RoxygenNote: 6.1.1
Encoding: UTF-8
and here is a minimal version of my documentation file:
\docType{data}
\name{teams}
\alias{teams}
\title{NHL Team Statistics 2007-2019}
\format{A data frame with 362 rows and 28 variables:
\describe{
\item{team}{Team name}
\item{season}{Season}
. . .
}}
\source{
\url{http://corsica.hockey/team-stats/}
}
\usage{
data(teams)
}
\description{
A dataset containing season-level statistics for NHL teams for all
game states (5v5, PP, PK). Includes regular season.
}
\keyword{datasets}
Why can't I access the datasets?
R prefers its datasets (things within ./data/
) to have a literal .rda
file ending.
I cloned your repo and ran devtools::check(...)
, and among other things saw:
Subdirectory 'data' contains no data sets.
When I renamed all .Rdata
files to .rda
and reloaded, it works.