r - 将 R_markdown 编织成 PDF 时加载命名空间出错

标签 r r-markdown knitr

第一次使用R_Markdown

我创建了一个新的 R_Markdown 并试图将它编织成 PDF。当我这样做时,出现以下错误


processing file: R_markdown.Rmd
  |..........                                                            |  14%
  ordinary text without R code

  |....................                                                  |  29%
label: setup (with options) 
List of 1
 $ include: logi FALSE

  |..............................                                        |  43%
  ordinary text without R code

  |........................................                              |  57%
label: cars
  |..................................................                    |  71%
  ordinary text without R code

  |............................................................          |  86%
label: pressure (with options) 
List of 1
 $ echo: logi FALSE

  |......................................................................| 100%
  ordinary text without R code


output file: R_markdown.knit.md

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS R_markdown.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output R_markdown.tex --lua-filter "C:\Users\faiel\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\faiel\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --variable "geometry:margin=1in" 
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  namespace 'xfun' 0.17 is already loaded, but >= 0.19 is required
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace
Execution halted

我不明白为什么会这样。我尝试了以下

install.packages("rmarkdown")

update.packages(ask = FALSE, checkBuilt = TRUE)
tinytex::tlmgr_update()

但没有任何运气

最佳答案

loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) 错误: namespace 'xfun' 0.17 已加载,但 >= 0.19 是必需的

如果您发现上述错误,您可以使用以下解决方案来消除错误。 同样的方法可以用于任何包。(代替 xfun 任何包名都可以存在)。

解决方案:
在 RStudio 中,导航至 -> 工具 -> 检查包更新,您可以在此处选择包并进行更新。 如果这不起作用,请更新 R 版本并尝试更新包。

通过执行上述方法,包将更新到较新的版本。

关于r - 将 R_markdown 编织成 PDF 时加载命名空间出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64701557/

相关文章:

r - doRedis 在 Ubuntu Linux、R 和 RStudio 中出现奇怪的套接字连接错误

r - “Erroneous nesting of equation structures”在rmarkdown中的多行方程式中使用“\begin{align}”到knit + pandoc pdf

r - Knitr:spin - 如何添加文本而不手动添加 #' 每行?

html - R中带有Knitr的高级html表-xtable包的替代品?

r - 编织为 PDF 时限制 Rstudio (3.1.1) 中函数的输出

r - 根据名称选择变量(简单的正则表达式)

r - 在时间序列图中标记一段时间

r - 使用 papaja 将图形编织成文字失败

html - 项目符号列表未在 blogdown .rmd 文件中呈现

r - Knitr和Rmarkdown docx表