RStudio, Packrat and Knitr

671 views Asked by At

I'm working in RStudio. I first created a knitr file in a project, and compiling the pdf worked flawlessly. Then, while I was working in different files, I activated packrat for the project. (And later on deactivated it again)

Now, when I try to Knitr (Compile pdf) my .Rnw file again, I get

Initializing packrat project in directory:
- "mydir"
Error in appDependencies(project) : 
  could not find function "available.packages"
Calls: source ... sort_c -> with_collate -> force -> sort -> appDependencies
Execution halted

I checked in RStudio's project options, and packrat is unchecked. Changing from Knitr to sweave did not help. Also, I ensured knitr is installed.

What can I do?

1

There are 1 answers

0
Kevin Ushey On BEST ANSWER

If you activated Packrat for your project, and for some reason packrat::disable() did not clean out the .Rprofile generated, you may need to remove it manually.

If there is an .Rprofile in the base directory of your project, and it contains e.g.

#### -- Packrat Autoloader (version 0.4.1.24) -- ####
source("packrat/init.R")
#### -- End Packrat Autoloader -- ####

you will need to remove that bit.

Alternatively, you can ensure that utils is loaded (available.packages is a function from utils) in your vignette; e.g. with library(utils).