Clarinetist
Clarinetist

Reputation: 1187

knitr will no longer compile: "Error in .First()"

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..

Upvotes: 0

Views: 177

Answers (1)

Clarinetist
Clarinetist

Reputation: 1187

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.

Upvotes: 4

Related Questions