“onLoad.R”是否应该包含在描述文件的“整理”字段中?

Ric*_*ven 5 r

我需要在加载包时显示免责声明消息。看完帖子后

\n\n

库/包开发 - 加载时的消息
\n使用 .onLoad 加载依赖包

\n\n

我现在有一个zzz.R文件只包含

\n\n
.onLoad <- function(libname, pkgname){\n    packageStartupMessage(\'Regarding data obtained from www.retrosheet.org:\\n\n    The information used here was obtained free of charge from  \n    and is copyrighted by Retrosheet. Interested parties may\n    contact Retrosheet at "www.retrosheet.org"\', domain = NULL, appendLF = TRUE)\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

我有两个问题:

\n\n
    \n
  1. 我需要打电话到.onLoad某个地方吗?或者这会自动发生吗?

  2. \n
  3. 我正在使用文件Collate中的字段DESCRIPTION。是否zzz.R需要添加到该列表中?

  4. \n
\n\n
\n\n

作为检查,我运行以下代码。包启动消息在使用时出现install,但在调用时不会出现library,这是我所期望的。

\n\n
> library(devtools)\n> install()\n...\nReloading installed saber\nRegarding data obtained from www.retrosheet.org:\n\nThe information used here was obtained free of charge from  \nand is copyrighted by Retrosheet. Interested parties may\ncontact Retrosheet at "www.retrosheet.org"\n...\n\n> detach(package:saber)\n> library(saber)\n\nAttaching package: \xe2\x80\x98saber\xe2\x80\x99\n\nThe following objects are masked _by_ \xe2\x80\x98.GlobalEnv\xe2\x80\x99:\n\n    getTeamData, relatedBatting\n
Run Code Online (Sandbox Code Playgroud)\n