如何在 R 和 RStudio 中构建 pdf 小插图

2024-05-06

我是编写 R 包的新手。我正在尝试学习如何为我的包裹制作小插图。我创建了一个小插图文件夹,其中包含文件“getting-started.Rmd”

---
title: "WaterML Tutorial"
author: "Jiri Kadlec"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Introduction to the WaterML R package}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

## Quick Start

This simple example shows how to get started with the <my R package>.

为了构建小插图,我使用以下命令:

devtools::build_vignettes()

然后我跑Rcmd.exe INSTALL my_package,并查看我的小插图,我运行:

browseVignettes("my_package")

However I only see the vignettes in the html and source format: I don't see the pdf option for vignettes

正如您在屏幕截图中看到的,没有“pdf”选项。如何配置 .Rmd 文件以创建 pdf 格式的小插图?


在你的标题中,你告诉 R 仅输出一个 html 小插图:

output: rmarkdown::html_vignette

如果你想要pdf,请尝试:

output: pdf_document

根据R 包 http://r-pkgs.had.co.nz/vignettes.html#vignettes:

输出:这告诉 rmarkdown 使用哪个输出格式化程序。有许多选项可用于常规报告(包括 html、pdf、幻灯片等),但 rmarkdown::html_vignette 专门设计用于在包内良好工作。有关更多详细信息,请参阅 ?rmarkdown::html_vignette。

因此,您在使用原始 pdf 时可能会遇到一些小问题。

此时,rmarkdown 还没有output: rmarkdown::pdf_vignette option

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 R 和 RStudio 中构建 pdf 小插图 的相关文章

随机推荐