Rstudio knit pdf in Rstudio loadNamespace(name): there is no package called 'rmarkdown'

纵然是瞬间 提交于 2019-12-12 10:47:45

问题


I just updated to Rstudio Version 0.98.1074. When I try to use compile notebook with a script or Knit pdf with an .rmd I get

Error in loadNamespace error: there is no package called 'rmarkdown'

yet I can type rmarkdown::render("filename.rmd") and it will render the document. I removed rmarkdown and re-installed with RStudio and it did not help. I've updated all my packages and I'm using R3.1.1.

This is a minor inconvenience since I have a workaround but thought I'd post in case there is a solution that I can't find.


回答1:


I received almost the exact same error when trying to use Rmarkdown on Windows, within Cygwin:

loadNamespace(name): there is no package called 'rmarkdown'

Everything worked fine within Rstudio, but didn't work when I tried to auto-knit some .Rmd files within Cygwin.

My library path in Rstudio:

.libPaths()
[1] "C:/Users/Gravitas/Documents/R/win-library/3.3" "C:/Program Files/R/R-3.3.2/library"

My library path as reported in Cygwin, when running C:\Program Files\R\R-3.3.2\bin\R.exe:

.libPaths()
[1] "C:/Program Files/R/R-3.3.2/library"

The problem:

  • When Rstudio is run in non-Administrator mode, it cannot write anything into C:/Program Files/R/R-3.3.2/library as this directory is write-protected.
  • Thus, Rstudio writes new packages into the user profile directory, which is freely writable.
  • However, Cygwin was not aware of the user's profile directory, so it could not find all of the newly installed packages.

The solution was to set this environment variable within Cygwin:

export R_LIB=C:/Users/Gravitas/Documents/R/win-library/3.3

Now, the path reported Cygwin is:

.libPaths()
[1] "C:/Users/Gravitas/Documents/R/win-library/3.3" "C:/Program Files/R/R-3.3.2/library"

And now, I can call bash scripts within Cygwin to auto-knit .Rmd files.



来源:https://stackoverflow.com/questions/26470909/rstudio-knit-pdf-in-rstudio-loadnamespacename-there-is-no-package-called-rma

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!