r - R CRAN 检查 : No repository set, 中的注释,因此跳过了循环依赖检查

标签 r package cran

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

* 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 中。仍然得到注释。

还有 Writing R Extensions 的第 1.3.1 节状态:

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 的结果吗?如果是这样,我该如何去做呢?还有其他可能导致该注释的原因或建议的修复吗?

最佳答案

From Writing R Extensions

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

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

推荐

用户应该仔细检查他的 .Rprofile 是否在他的家里并且它包含提到的选项。

# 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 session 使用额外的包:

library(pathological)
r_profile()

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

# 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 个关于新提交的注释。

  1. 首先复制/粘贴代码并将其源到您的 R session 中(--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 不存在,则无论如何都会创建它并在文件末尾添加一个新行。

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 选项绕过站点配置文件(在第二步中)。

PDF 错误

您可能会遇到 PDF 和 Latex 相关错误,这很可能是由于缺少或不完整 Latex 安装造成的。您可以使用 --no-manual 选项跳过 PDF 测试。

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

关于r - R CRAN 检查 : No repository set, 中的注释,因此跳过了循环依赖检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23164929/

相关文章:

R DataFrame - 包含多个术语的列的一种热编码

R SF : st_intersection on a list of polygons

r - 如何找到特定形状的边界点

oracle - 包的初始化部分

java - 如何在Java中正确组织和嵌套包

r - 可以声明包依赖项的显式版本吗?

java - 从 Github URL 下载包 JAR 到 R 包中的/inst/java

r - 手册和小插图有什么区别?

java - java中包的使用

r - 在自定义的JupyterHub用户笔记本图像中包括其他R pkg吗?