knitr将不再编译:".First()中的错误" [英] knitr will no longer compile: "Error in .First()"

查看:81
本文介绍了knitr将不再编译:".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 running R by Sys.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屋!

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