简体   繁体   English

Rstudio编织为PDF

[英]Rstudio knit to PDF

The new version of Rstudio (0.98.932) has many new options including knit to PDF. 新版Rstudio(0.98.932)有许多新选项,包括针织到PDF。 An article describing the new version has a comment from Dave that says: 一篇描述新版本的文章有来自Dave评论说:

...after installing rstudio 0.98.932 I don't get the little dropdown menu for knit-pdf or word when editing a .Rmd file. ...安装rstudio 0.98.932后,在编辑.Rmd文件时,我没有获得knit-pdf或word的小下拉菜单。

I'm having the same issue. 我有同样的问题。 A helpful response was posted: 发布了有用的回复:

It might be that either: 它可能是:

a) You are not running R 3.0 (which is required for RMarkdown v2); a)您没有运行R 3.0(RMarkdown v2需要); or 要么

b) You have a custom markdown renderer defined (markdownToHTML option). b)您定义了自定义降价渲染器(markdownToHTML选项)。 You can check for this by executing: 您可以通过执行以下操作来检查:

getOption(“rstudio.markdownToHTML”) getOption(“rstudio.markdownToHTML”)

That solved Dave's problem (b), but when I run that command I get NULL 这解决了Dave的问题(b),但是当我运行该命令时,我得到了NULL

> getOption("rstudio.markdownToHTML")
NULL

Which I assume means I don't have a custom markdown renderer defined. 我假设这意味着我没有定义自定义降价渲染器。 (Previously I did in a cusomized .Rprofile , but I removed that.) My R version is 3.1.0. (之前我做过一个cusomized .Rprofile ,但我删除了。)我的R版本是3.1.0。

Am I misunderstanding the getOption command? 我误解了getOption命令吗? Could something else be tripping up my Rstudio? 还有其他东西会绊倒我的Rstudio吗?

I have just installed the new version of RStudio (0.98.932), which prompted me to upgrade a couple of packages (I can't remember which, although I see I have knitr 1.6, markdown 0.7 and rmarkdown 0.2.46). 我刚刚安装了新版本的RStudio(0.98.932),这促使我升级了几个软件包(我不记得哪个,虽然我看到我有knitr 1.6,markdown 0.7和rmarkdown 0.2.46)。 At first I had the same problem; 起初我遇到了同样的问题; there was only a single 'knit' option on the tool bar. 工具栏上只有一个“编织”选项。 I managed to get the ability to knit to .pdf by adding the following to the head of my .Rmd file. 我设法通过将以下内容添加到我的.Rmd文件的头部来获得编织.pdf的能力。

---
title: "Sample Document"
output: pdf_document
---

Having done that, I now find I do have a drop down menu with options to knit to HTML, PDF and word. 完成后,我现在发现我有一个下拉菜单,可以选择编织HTML,PDF和单词。 There's also a little gear icon that provides access to the R Markdown document options that wasn't there before. 还有一个小齿轮图标,可以访问以前没有的R Markdown文档选项。 I have no idea what the problem was but it seems OK now! 我不知道问题是什么,但现在看来还可以!

Adding on @nicholas response This is also why I create new .Rmd documents through the RStudio gui 添加@nicholas响应这也是我通过RStudio gui创建新的.Rmd文档的原因

File > New File > R markdown. 文件>新文件> R降价。

This way the YAML header is populated correctly. 这样就可以正确填充YAML标头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM