RStudio can't find my library on startup

2019-02-23 05:10发布

问题:

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.

回答1:

I decided to start clean, I re-installed both R and RStudio and deleted my old library. Running R (or RStudio) as an administrator allowed me to install into the default library, which avoids the problems of using a separate library. A work-around, but I can Knit again!



标签: r rstudio