R CRAN 检查中的注意事项:未设置存储库,因此跳过了循环依赖检查 [英] NOTE in R CRAN Check: No repository set, so cyclic dependency check skipped

查看:18
本文介绍了R CRAN 检查中的注意事项:未设置存储库,因此跳过了循环依赖检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从 R 3.1.0 开始,我得到以下 R 检查:

As of R 3.1.0 I get the following R check:

* checking package dependencies ... NOTE
  No repository set, so cyclic dependency check skipped

我尝试了这个建议:https://twitter.com/phylorich/status/431911660698083328

不行.我将行 options(repos="http://cran.rstudio.com/") 放在包根目录的 .Rprofile 中.仍然得到笔记.

No go. I put the line options(repos="http://cran.rstudio.com/") in a .Rprofile in the package root directory. Still get the Note.

还有 的第 1.3.1 节编写 R 扩展 状态:

Some Windows users may need to set environment variable R_WIN_NO_JUNCTIONS 
to a non-empty value. The test of cyclic declarations33in DESCRIPTION 
files needs repositories (including CRAN) set: do this in ~/.Rprofile.

这可能是 设置环境变量 R_WIN_NO_JUNCTIONS 的结果吗?如果是这样,我该怎么做?注释或建议修复的任何其他可能原因?

Is this possibly a result of the set environment variable R_WIN_NO_JUNCTIONS? If so how can I go about doing this? Any other possible causes of the note or suggested fixes?

推荐答案

来自编写 R 扩展

DESCRIPTION 文件中的循环声明测试需要存储库(包括 CRAN)集:在 ~/.Rprofile 中执行此操作,例如

The test of cyclic declarations in DESCRIPTION files needs repositories (including CRAN) set: do this in ~/.Rprofile, by e.g

options(repos = c(CRAN="http://cran.r-project.org"))

推荐

用户应仔细检查他的 .Rprofile 是否在他的家中,并且是否包含上述选项.

User should double check if his .Rprofile is in his home and that it contains the mentioned option.

# in R session (any platform)
# where is my profile?
file.path(Sys.glob("~"),".Rprofile")
# is it there?
file.exists(file.path(Sys.glob("~"),".Rprofile"))

或者从 R 会话中使用额外的包:

Or from R session using extra package:

library(pathological)
r_profile()

用户应仔细检查选项条目是否未嵌套在 IF 条件中,如以下代码所示:

User should double check if the option entry is not nested in the IF condition, like in the following code:

# this will not help for R CMD check --as-cran
if(interactive()) {
options(repos = c(CRAN="http://cran.r-project.org"))
}

适用于任何平台的试运行

这里是 R 脚本,准备简单的 R 包临时案例进行测试,有助于更快地发现本地使用中的问题.这种方法帮助我自己找到了我的 .Rprofile 文件中的问题,并且通常可以帮助设置工作初始状态.在最好的情况下,检查运行应该只显示关于新提交的 1 条注释.

Here is R script preparing easy temporary case of R package for testing, helping to faster find what is going wrong in your local usage. This aproach helped myself to locate what was wrong in my .Rprofile file and generally can help to set up working initial state. In best case, the check run should show only 1 NOTE about new submission.

  1. 首先复制/粘贴代码并在您的 R 会话中获取源代码 (--vanilla最好)
  2. 然后运行脚本打印的命令检查测试用例--as-cran.

示例

# for example
R --vanilla -f makePackage.R
# here the resulting package path is as below
R --no-site-file CMD check --as-cran /tmp/pkgtest
# now see the check log

如果您的 .Rprofile 不存在,它将被创建,并且无论如何都会在文件末尾放置一个新行.

If your .Rprofile does not exist it will be created and one new line placed at the end of file in any case.

makePackage.R 脚本

# makePackage.R
# makes simple package for playing with check --as-cran

# copy this content to file makePackage.R
# then source it into your R --vanilla session

name <- "pkgtest"

#
# prepare and adjust package template
#

tempbase <- dirname(tempdir())
e <- new.env()
path <- dirname(tempdir())

# make simple package in path
e$fu <-  function(){"Hello"}
package.skeleton(name=name,force=T,path=path,environment=e)
nil <- file.remove(
    file.path(path,name,'Read-and-delete-me'),
    file.path(path,name,'man',paste0(name,'-package.Rd'))
    )

# adjust DESCRIPTION
D <- readLines(file.path(path,name,"DESCRIPTION"))
D[grepl("^Title: ",D)] <- "Title: Testing Skeleton"
D[grepl("^Author: ",D)] <- "Author: John Doe"
D[grepl("^Description: ",D)] <- "Description: Checking --as-cran check."
D[grepl("^Maintainer: ",D)] <- "Maintainer: John Doe <jdoe@doe.net>"
D[grepl("^License: ",D)] <- "License: GPL (>= 2)"
write(D,file.path(path,name,"DESCRIPTION"))

# make fu.Rd
write(
"\name{fu}\alias{fu}\title{Prints}\description{Prints}
\usage{fu()}\examples{fu()}",
file.path(path,name,'man','fu.Rd'))

#
# ensure that .Rprofile contains repos option 
# add fresh new line et the end of .Rprofile
# 

userRp <- file.path(Sys.glob("~"),".Rprofile")
write("options(repos = c(CRAN='http://cran.r-project.org'))",file=userRp, append=TRUE)

#
# print final message
#

msg <- sprintf("
Your test package was created in %s,
under name %s,
your user .Rprofile in %s was modified (option repos),
now check this test package from command line by command:

R --no-site-file CMD check --as-cran %s
", path, name,  userRp, file.path(path,name) 
)

# now is time to check the skeleton
message(msg)

检查包裹

# replace package-path by the path adviced by the sourcing the script above
R --no-site-file CMD check --as-cran package-path

有用户配置文件和站点配置文件,在上述方法中,您通过使用 --no-site-file 选项作为包骨架选项绕过站点配置文件(在第二步中).

There is user profile and site profile, in the approach above you bypasses site profile (in second step) by using --no-site-file option for package skeleton option.

PDF 错误

您可能会遇到与 PDF 和乳胶相关的错误,这很可能是由于乳胶安装丢失或未完成造成的.您可以使用 --no-manual 选项跳过 PDF 测试.

You can experience PDF and latex related errors, caused very likely by missing or not complete latex instalation. Ycan use --no-manual option to skip PDF tests.

R --no-site-file CMD check --no-manual --as-cran /tmp/pkgtest

这篇关于R CRAN 检查中的注意事项:未设置存储库,因此跳过了循环依赖检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆