如何在R和RStudio中构建pdf小插图 [英] How to build a pdf vignette in R and RStudio

查看:217
本文介绍了如何在R和RStudio中构建pdf小插图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始编写R包.我正在尝试学习如何为我的包裹制作小插图.我用文件"getting-started.Rmd"创建了一个小插图文件夹

I am new to writing R packages. I'm trying to learn how to make a vignette for my package. I have created a vignettes folder with a file "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>.

要构建小插图,请使用以下命令:

To build the vignette I use the command:

devtools::build_vignettes()

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

Then I run Rcmd.exe INSTALL my_package, and to view my vignette I run:

browseVignettes("my_package")

但是,我只能以html和源格式看到小插图:

However I only see the vignettes in the html and source format:

如屏幕截图所示,没有"pdf"选项.如何配置.Rmd文件以创建pdf格式的小插图?

As you see in the screenshot, there's no "pdf" option. How do I configure my .Rmd file to create my vignette in the pdf format?

推荐答案

在标头中,您告诉R仅在一行中输出html小插图:

In your header, you are telling R to output only an html vignette in line:

output: rmarkdown::html_vignette

如果要使用pdf,请尝试:

If you want pdf, try:

output: pdf_document

根据 R包:

输出:告诉rmarkdown使用哪个输出格式化程序.有许多对常规报告有用的选项(包括html,pdf,幻灯片,…),但是rmarkdown :: html_vignette经过专门设计,可以在包中很好地工作.有关更多详细信息,请参见?rmarkdown :: html_vignette.

Output: this tells rmarkdown which output formatter to use. There are many options that are useful for regular reports (including html, pdf, slideshows, …) but rmarkdown::html_vignette has been specifically designed to work well inside packages. See ?rmarkdown::html_vignette for more details.

因此,使用原始pdf文件可能会遇到一些小问题.

So you might have a few small problems using a raw pdf.

目前,rmarkdown没有output: rmarkdown::pdf_vignette选项

At this time, rmarkdown does not have a output: rmarkdown::pdf_vignette option

这篇关于如何在R和RStudio中构建pdf小插图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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