knitr将不再编译:".First()中的错误" [英] knitr will no longer compile: "Error in .First()"
问题描述
今天(通过RStudio)打开R时,我在控制台中看到以下红色文字:
Loading required namespace: ffbase
Error in .First() : could not find function "load.ffdf"
这也显示在基本R中.我今天尝试通过knitr编译.rnw
文件(使用RStudio),并看到以下内容:
Loading required namespace: ffbase
Error in .First() : could not find function "load.ffdf"
Execution halted
我以前从未见过此问题,.rnw
编译在过去一直有效,并且没有搜索帮助我解决此问题.
我对.Rprofile
文件没有经验.当我键入.First
时,得到以下信息:
> .First
function ()
{
if (!requireNamespace("ffbase")) {
stop("Please install package ffbase, otherwise the files cannot be loaded.")
}
env <- load.ffdf(".", parent.frame())
}
我不确定这是哪里来的,默认情况下是什么,等等.
我通过以下操作解决了此问题.
从?.First
开始.
它在文档中指出:
R搜索用户个人资料,即R代码的文件.该文件的路径 可以由
R_PROFILE_USER
环境变量指定(并且 将执行波浪符号扩展).如果未设置,则名为 在当前目录或目录中搜索‘.Rprofile’
用户的主目录(按此顺序).用户配置文件是 源到工作区....
接下来,如果在搜索路径中找到功能
.First
,则为 以.First()
执行....
有关Windows上主目录"的定义,请参见"
rw-FAQ
" Q2.14.可以通过Sys.getenv("R_USER")
从正在运行的R
中找到它.
当前目录中没有.Rprofile
文件,因此我使用Sys.getenv("R_USER")
将我带到主目录,该目录具有已删除的.Rprofile
文件,现在错误消失了. /p>
When I opened R today (via RStudio), I saw the following come up in red text in the Console:
Loading required namespace: ffbase
Error in .First() : could not find function "load.ffdf"
This is also showing up in base R. I tried compiling an .rnw
file via knitr today (using RStudio) and saw the following:
Loading required namespace: ffbase
Error in .First() : could not find function "load.ffdf"
Execution halted
I've never seen this issue before, the .rnw
compilation has worked in the past, and no searching has helped me get around this issue.
I have no experience with .Rprofile
files. When I typed in .First
, I get the following:
> .First
function ()
{
if (!requireNamespace("ffbase")) {
stop("Please install package ffbase, otherwise the files cannot be loaded.")
}
env <- load.ffdf(".", parent.frame())
}
I'm not sure where this is coming from, what it is by default, etc..
I solved this issue by doing the following.
Start by doing ?.First
.
It states in the documentation:
R searches for a user profile, a file of R code. The path of this file can be specified by the
R_PROFILE_USER
environment variable (and tilde expansion will be performed). If this is unset, a file called‘.Rprofile’
is searched for in the current directory or in the user's home directory (in that order). The user profile file is sourced into the workspace....
Next, if a function
.First
is found on the search path, it is executed as.First()
....
For the definition of the ‘home’ directory on Windows see the ‘
rw-FAQ
’ Q2.14. It can be found from a runningR
bySys.getenv("R_USER")
.
I did not have a .Rprofile
file in the current directory, so I used Sys.getenv("R_USER")
which led me to the home directory, which had a .Rprofile
file which I deleted, and now the error is gone.
这篇关于knitr将不再编译:".First()中的错误"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!