我正在构建一个包含多个数据集的R包。我在“ data”文件夹中将数据集另存为.RData对象,并且每个数据集都有使用roxygen2
生成的文档。当我安装该软件包时,加载它并尝试调用数据集,
devtools::install_github("jamesmartherus/nhldata")
library(nhldata)
data(teams)
我收到此错误:
In data("teams") : data set ‘teams’ not found
这是我的Description文件的内容:
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
这是我的文档文件的最低版本:
\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}
为什么我不能访问数据集?
答案 0 :(得分:3)
R希望其数据集(./data/
中的内容)的字面量为.rda
文件结尾。
我克隆了您的存储库并运行devtools::check(...)
,其中包括:
Subdirectory 'data' contains no data sets.
当我将所有.Rdata
个文件重命名为.rda
并重新加载后,它就可以工作了。