首页 > 解决方案 > Knitr 未加载/未找到?

问题描述

我最近将 RStudio 更新为 3.6.2 以获取一个包或我在 3.5 版本上无法使用的东西。但是,我不知道我的 knitr 问题是在更新之前还是之后开始的。我从呈现 rmarkdown 的 R 脚本开始。一旦开始渲染,它会说:

> rmarkdown::render(input = "file.rmd", params=list(Start_Date = rpt .... [TRUNCATED] 
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  there is no package called ‘knitr’

Knitr 没有显示更新,当我尝试再次安装它时,它说:

> install.packages("knitr")

  There is a binary version available but the source version is later:
      binary source needs_compilation
knitr   1.27   1.28             FALSE

installing the source package ‘knitr’

trying URL 'https://cran.rstudio.com/src/contrib/knitr_1.28.tar.gz'
Content type 'application/x-gzip' length 884866 bytes (864 KB)
downloaded 864 KB

'\\file\path_file\myname'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
'\\file\path_file\myname\R\R-3.6.2' is not recognized as an internal or external command,
operable program or batch file.
Warning in install.packages :
  installation of package ‘knitr’ had non-zero exit status

The downloaded source packages are in
    ‘K:\Users\AppData\Local\Temp\RtmpoJyMI4\downloaded_packages’

我真的不知道为什么会这样。我上周运行的这些文件运行良好。如果我缺少更多信息,请告诉我。

标签: rr-markdownknitr

解决方案


更新:Windows 二进制文件现在在 CRAN 上可用;install.packages("knitr")应该可以工作。


我不知道为什么 CRAN 上还没有最新的 Windows 二进制版本的knitr,但您不必安装最新版本。您可以options(install.packages.check.source = "no")在安装软件包之前进行设置,它将安装较旧的二进制版本。

或者再等几天,直到在 CRAN 上提供二进制版本:https ://cran.r-project.org/package=knitr 。


推荐阅读