Rstudio loadNamespace(name)中的Rstudio编织pdf:没有名为'rmarkdown'的软件包 [英] Rstudio knit pdf in Rstudio loadNamespace(name): there is no package called 'rmarkdown'

查看:72
本文介绍了Rstudio loadNamespace(name)中的Rstudio编织pdf:没有名为'rmarkdown'的软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚更新到Rstudio版本0.98.1074.当我尝试使用带有脚本的编译笔记本或带有.rmd的Knit pdf时得到

loadNamespace错误:没有名为'rmarkdown'的软件包

但是我可以键入rmarkdown::render("filename.rmd"),它将呈现文档.我删除了rmarkdown并重新安装了RStudio,但没有帮助.我已经更新了所有软件包,并且正在使用R3.1.1.

这是一个小小的麻烦,因为我有一种解决方法,但是我认为我会在找不到解决方案的情况下发布.

解决方案

在Cygwin中尝试在Windows上使用Rmarkdown时,我收到几乎完全相同的错误:

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

在Rstudio中,一切工作正常,但是当我尝试在Cygwin中自动编织某些.Rmd文件时,一切都没有效果.

我在Rstudio中的库路径:

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

运行C:\Program Files\R\R-3.3.2\bin\R.exe时在Cygwin中报告的我的库路径:

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

问题:

  • 以非管理员模式运行Rstudio时,由于该目录受写保护,因此无法将任何内容写入C:/Program Files/R/R-3.3.2/library.
  • 因此,Rstudio将新程序包写入用户配置文件目录,该目录可自由写入.
  • 但是,Cygwin不知道用户的配置文件目录,因此找不到所有新安装的软件包.

解决方案是在Cygwin中设置此环境变量:

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

现在,Cygwin报告的路径为:

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

现在,我可以在Cygwin中调用bash脚本来自动编织.Rmd files.

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.

解决方案

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.

这篇关于Rstudio loadNamespace(name)中的Rstudio编织pdf:没有名为'rmarkdown'的软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆