问题
I am testing knitr in R-Studio (with MacOS 10.10.3) in a Markdown file with the following code chunk:
```{r}
summary(cars)
```
The compilation stops with the following message:
processing file: Preview-13c324b5a94e.Rmd
Warning: namespace 'formatR' is not available and has been replaced
by .GlobalEnv when processing object 'silent'
Quitting from lines 13-14 (Preview-13c324b5a94e.Rmd)
Error in loadNamespace(name) : there is no package called 'evaluate'
Calls: <Anonymous> ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
However, typing summary(cars)
in the R-Console produces the expected output. I also have tried changing the working directory but no luck.
Any ideas?
回答1:
I was also having the similar issue with below error :
Warning: namespace 'evaluate' is not available and has been replaced by .GlobalEnv when processing object''
1- Root Cause : package "evaluate" was not properly installed, so remove it and install again :
remove.packages("evaluate", lib="~/R/win-library/3.2")
install.packages("evaluate")
2- so when I tried to load the package evaluate ,I started getting below error:
library("evaluate", lib.loc="~/R/win-library/3.2") Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no package called ‘stringi’ In addition: Warning message: package ‘evaluate’ was built under R version 3.2.5 Error: package or namespace load failed for ‘evaluate’
3- I installed the package "stringi" again and problem was resolved. :)
回答2:
Yihui, have you seen this probelm before?
I was able to solve the above problem by switching to my MacAir laptop which runs Mac OS X 10.9.5 (with RStudio 0.98.1103 and Tex Live 10/29/13 version). With this setup, the test program shown above and my more elaborate mtcars analysis program ran smooth as silk! To my uninformed mind, it would seem like Mac OS Yosemite 10.10.3 (on my desktop Mac) and knitr (or Tex Live) have some incompatibility. Interestingly, I tried simple in-line r code such as
{r} 1+1
and this worked fine.
Anyway, I was able to solve my immediate problem but would be curious to know the root cause.
来源:https://stackoverflow.com/questions/30339255/knitr-not-recognizing-r-code-chunks