在我的R Markdown文档中,我有时想要生成一个报告而不显示实际代码(特别是当我发送给我的老板时).如何隐藏R代码并显示图表和结果?
例如:
---
output: html_document
---
```{r fig.width=16, fig.height=6}
plot(cars)
```
Run Code Online (Sandbox Code Playgroud)
这显示了命令和绘图.如何从HTML报告中删除命令?
当我使用render {rmarkdown}从我的Mac上的.Rmd文件生成pdf文件时,会显示一条错误消息
pandoc: pdflatex not found. pdflatex is needed for pdf output.
Error: pandoc document conversion failed
但是当我检查时
pdflatex -v
Run Code Online (Sandbox Code Playgroud)
我有
pdfTeX 3.1415926-2.4-1.40.13 (TeX Live 2012)
kpathsea version 6.1.0
Copyright 2012 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of …Run Code Online (Sandbox Code Playgroud) 我试图在用knitr/rmarkdown制作的PDF中交叉引用数字和表格.关于SO和tex.stackexchange(这里和这里,例如)有一些问题,建议内联的方法是添加\ref{fig:my_fig},my_fig块标签在哪里.但是,当我在我的rmarkdown文档中尝试时,我会得到??图号应该在哪里.我想了解如何使交叉引用正常工作.
可重复的例子如下.有两个文件:rmarkdown文件加上header.tex我包含的文件,以防它影响答案(尽管我是否包含header.tex文件也有同样的问题).
在该rmarkdown文件中有三个交叉引用示例.示例1是交叉引用失败的图(??显示而不是图号).还有第二个注释掉的尝试(基于这个SO答案),我尝试latex在块之前和之后用标记设置图形环境,标签和标题,但是pandoc当我尝试编织文档时这会导致错误.错误是:
Run Code Online (Sandbox Code Playgroud)! Missing $ inserted. <inserted text> $ l.108 , '%B %e, %Y')`"
output:
pdf_document:
fig_caption: yes
includes:
in_header: header.tex
keep_tex: yes
fontsize: 11pt …Run Code Online (Sandbox Code Playgroud) 我正在使用RStudio来编写我的R Markdown文件.如何删除##代码输出之前显示的最终HTML输出文件中的哈希()?
举个例子:
---
output: html_document
---
```{r}
head(cars)
```
Run Code Online (Sandbox Code Playgroud)
更新:Brandon Bertelsen的回答:
布兰登的答案产生以下输出.它不会像Rstudio那样产生漂亮的表格或突出显示代码,并且它会在一些带有unicode的html文件上崩溃,因此我不会使用它来自动化我的电子邮件报告.
我目前的方法是使用Rstudio编译为html,在chrome中打开html文档,然后将html文档复制并粘贴到gmail中.这很好用,请看这个要点:https://gist.github.com/nelsonauner/a68b5a808c232ce7817e
是否有一种简单的方法可以将R降价文档作为电子邮件正文发送,以便电子邮件的正文与使用Rstudio的"编织HTML"的结果类似?
这里有一个基本的可重复使用例子knitr,rmarkdown和mailR
---
title: "Report for email"
output:
html_document:
self_contained: no
---
```{r}
summary(cars)
```
You can also embed plots, for example:
```{r, echo=FALSE}
plot(cars)
```
Run Code Online (Sandbox Code Playgroud)
我正在使用,self_contained: no因为默认的base64编码不起作用mailR(Yihui在此SO帖子中推荐)
# compile using rmarkdown
library(rmarkdown)
rmarkdown::render("example.Rmd")
library(mailR)
send.mail(from = "me@gmail.com",
to = "me@gmail.com",
subject = "R Markdown Report - rmarkdown",
html = T,
inline = T,
body = "example.html",
smtp …Run Code Online (Sandbox Code Playgroud) 我从我的应用程序闪亮生成pdf报告时遇到问题,该报告托管在服务器上.
该应用程序工作正常,但当我按下按钮下载报告时,我收到此错误:
pandoc version 1.12.3 or higher is required and was not found.
Run Code Online (Sandbox Code Playgroud)
问题是,如果我输入pandoc -v我得到:
pandoc 1.12.3.3
Compiled with texmath 0.6.6, highlighting-kate 0.5.6.1.
Syntax highlighting is supported for the following languages:
actionscript, ada, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog,
clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d,
diff, djangotemplate, doxygen, doxygenlua, dtd, eiffel, email, erlang,
fortran, fsharp, gnuassembler, go, haskell, haxe, html, ini, java, javadoc,
javascript, json, jsp, julia, latex, lex, literatecurry, literatehaskell, …Run Code Online (Sandbox Code Playgroud) 在R markdown(knitr包)中,我可以访问在代码块中计算的文档正文中的变量吗?
有没有办法配置Emacs,以便它识别(并允许执行)R markdown(.Rmd)文件中的R代码块,类似于它识别.Rnw(Sweave)或.org(org-mode)中的代码块的方式文件?
我正在使用R 3.1和RStudio 0.99运行矩阵.
我有我的R脚本和cmd +输入它没有问题.
我为报告创建了一个Rmd,但是我有这个错误
Error in lazyLoadDBinsertVariable(vars[i], from, datafile, ascii, compress, :
long vectors not supported yet: ../../../../R-3.3.1/src/main/connections.c:5600
Calls: <Anonymous> ... <Anonymous> -> <Anonymous> -> lazyLoadDBinsertVariable
Execution halted
Run Code Online (Sandbox Code Playgroud)
有没有办法绕过这个错误?
但不同之处在于,这仅在尝试创建Rmd时发生,而不是在任何其他情况下
我正在尝试按照此pandoc示例将多个作者添加到yaml元数据块中的Rmarkdown文件.pdf将在RStudio(版本0.98.932)中生成,但没有作者信息.
---
title: 'This is the title: it contains a colon'
author:
- name: Author One
affiliation: University of Somewhere
- name: Author Two
affiliation: University of Nowhere
date: "`r format(Sys.time(), '%d %B %Y')`"
tags: [nothing, nothingness]
abstract: |
This is the abstract.
It consists of two paragraphs.
output: pdf_document
---
Run Code Online (Sandbox Code Playgroud)
我还想更多地定制标题并添加一个副标题.可能?