Ric*_*ven 5 dependencies packages r dataset
我正在尝试构建一个依赖于另一个包中的一些数据的包. 编写R Extensions说要避免使用requirein package函数.我可能不会使用Lahman包中的所有表,并且我目前正在以这种方式导入它们...
team.batting <- function(year, league, playoffs = FALSE)
{
...
Batting <- Lahman::Batting
Teams <- Lahman::Teams
## calculations, subsets, etc.
...
}
Run Code Online (Sandbox Code Playgroud)
它是否正确?如果没有,在包函数中调用导出数据集的正确方法是什么?最终用户是否需要安装软件包才能使用?
此外,与安装版本相比,我不清楚开发版本是什么.如果有人可以发光,我会很感激.
经过一番研究,我确定执行此操作的正确方法是包含指令
import(Lahman)
Run Code Online (Sandbox Code Playgroud)
在我的包的 NAMESPACE 文件中(或者可能importFrom(Lahman, table name)取决于使用的表数量)。执行此操作后,::可以删除呼叫。
team.batting <- function(year, league, playoffs = FALSE)
{
...
bat <- Batting
tms <- Teams
## calculations, subsets, etc.
...
}
Run Code Online (Sandbox Code Playgroud)