【发布时间】:2014-06-04 11:19:07
【问题描述】:
我在使用 devtools 函数时遇到了非常奇怪的副作用。这是一个简单的例子。 基本上,我启动一个干净的 R 会话,创建一个空包,然后使用 load_all 加载新包。一旦我这样做了,帮助功能就不再起作用了。这是屏幕截图:
R version 3.1.0 (2014-04-10) -- "Spring Dance"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: i386-w64-mingw32/i386 (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> setwd("c:/Scratch")
> require(devtools)
Loading required package: devtools
Attaching package: ‘devtools’
The following objects are masked from ‘package:utils’:
?, help
The following object is masked from ‘package:base’:
system.file
> help("data.frame")
starting httpd help server ... done
> create("mypackage",rstudio=F)
Creating package mypackage in .
No DESCRIPTION found. Creating with values:
Package: mypackage
Title: What the package does (short line)
Version: 0.1
Authors@R: "First Last <first.last@example.com> [aut, cre]"
Description: What the package does (paragraph)
Depends: R (>= 3.1.0)
License: What license is it under?
LazyData: true
> help("data.frame")
> load_all("mypackage")
Loading mypackage
> help("data.frame")
Error in names(t1) <- rep(names(L), lapply(L, length)) :
attempt to set an attribute on NULL
>
这是会话信息:
> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: i386-w64-mingw32/i386 (32-bit)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] mypackage_0.1 devtools_1.5
loaded via a namespace (and not attached):
[1] digest_0.6.4 evaluate_0.5.5 httr_0.3 memoise_0.2.1 parallel_3.1.0 RCurl_1.95-4.1 stringr_0.6.2 tools_3.1.0 whisker_0.3-2
>
帮助命令不起作用只是一个例子,我注意到还有一些其他奇怪的东西。像 data.table 子集功能不再起作用。如果您能给我一些解决问题的方法,我将不胜感激。
【问题讨论】:
-
你有没有机会在
./data或默认load_all看起来的类似目录中找到? -
感谢您的帮助。我看了看,但包是在一个空目录中从头开始创建的。我用--no-init-file --no-restore 启动R。并且 ls() 返回空。
-
接下来要尝试的是
utils::help('data.frame'),以验证devtools::help是否存在问题。 -
utils::help('data.frame')有效,但devtools::help('data.frame')无效,这是回溯6: invert(lapply(rds, aliases)) 5: build_topic_index(pkg) 4: topic_index(pkg) 3: find_pkg_topic(path, topic) 2: find_topic(topic_str) 1: help("aaa")