我已经很高兴从 RMarkdown 文件生成 PDF 文件有一段时间了。最近,当创建PDF文件时,出现了一个我不明白的新警告——它出现only在 PDF 文件中(即 .Rmd 文件中没有显示相同消息的输出)。错误是:
## Warning in !is.null(rmarkdown::metadata$output) && rmarkdown::$output
## %in% : 'length(x) = 3 > 1' in coercion to 'logical(1)'
我从来没有见过像这样的东西,在谷歌搜索了一段时间后,我发现没有任何东西似乎有用。我在新的 R 会话中尝试过此操作,并且警告是相同的。我的所有软件包都是最新的,并且我正在运行 R 版本 4.2.1。
关于如何解决这个问题有什么想法吗?或者(因为它“只是一个警告”)如何阻止它在我的 PDF 中生成消息?
作为参考,以下是 .Rmd 文件的 yaml 部分:
---
title: "Title Notebook"
author:
- Name
date: "Last compiled on `r format(Sys.time(), '%d %B %Y')`"
output:
pdf_document:
highlight: tango
keep_tex: yes
number_sections: yes
toc: yes
fig_caption: yes
extra_dependencies:
array: null
caption: null
graphicx: null
siunitx: null
multirow: null
calc: null
tabularx: null
threeparttable: ["para", "online", "flushleft"]
hyperref: null
html_notebook:
number_sections: yes
toc: yes
fig_caption: yes
df_print: paged
html_document:
toc: yes
fig_caption: yes
df_print: paged
classoption: "nopatch"
这是设置块:
```{r setup, echo = FALSE, message = FALSE, results = 'hide'}
# Packages/Libraries can go here:
# Options
knitr::opts_chunk$set(
echo = TRUE,
# echo = FALSE,
collapse = TRUE,
warning = FALSE,
message = FALSE,
comment = "#>",
fig.retina = 2, # Control using dpi
fig.width = 6, # generated images
fig.pos = "t", # pdf mode
fig.align = "center",
dpi = 300,
out.width = "100%",
dev = "png",
optipng = "-o1 -quiet")
```