Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RStudio can't find my library on startup

Tags:

r

rstudio

A couple weeks ago I asked this question on the RStudio support forums, but it hasn't been addressed there, so I'm trying here.

I'm using RStudio 0.97.248 (current version) on Windows 7 and R 2.15.2.

When I open RStudio, after the normal R version info, I am presented with two errors:

Error in packageVersion("knitr") : package ‘knitr’ not found  Error in
packageVersion("Rcpp") : package ‘Rcpp’ not found

but I can load both packages without a problem using require(). (That is, after the errors on starting RStudion, I can enter require(knitr) and knitr will load successfully. The real problem is that I can't use, for example, the Knit HTML command on an R Markdown document, even after manually loading knitr. If I load knitr with require(knitr), then open a new R Markdown document (for which RStudio defaults to a nice template), save it and attempt to Knit HTML, RStudio gives me a little error message at the top of the R Markdown document that

R Markdown requires the knitr package (version 0.5 or higher)

I'm assuming RStudio isn't looking at the correct library paths.

> .libPaths()
[1] "\\\\gregorp.homedir.nebula.washington.edu/homes/R/win-library/2.15"
[2] "C:/Program Files/R/R-2.15.2/library"                               
[3] "C:/Program Files/RStudio/R/library"

with the first entry being where I can and do install packages (and my Rcpp and knitr installations are located). I think I'm having the same issue as this guy, but that discussion is incoherent.

I tried adding the line

.Library.site <- "\\\\gregorp.homedir.nebula.washington.edu/homes/R/win-library/2.15"

to my Rprofile.site file in my R-2.15.2/etc/ folder, but the problem persists.

like image 376
Gregor Thomas Avatar asked Oct 06 '22 10:10

Gregor Thomas


1 Answers

I decided to start clean, I re-installed both R and RStudio and deleted my old library.

A risky option is running R (or RStudio) as an administrator---this allowed me to install into the default library, which avoids the problems of using a separate library.

In newer versions of RStudio I've had no problems using a separate library, specifying the site library in my Rprofile.site file.

like image 94
Gregor Thomas Avatar answered Oct 10 '22 12:10

Gregor Thomas