在创建Rmd文件时,我包含了一个内部超链接:
[hlink](#id1)
Run Code Online (Sandbox Code Playgroud)
然后进一步锚定
<a id="id1"></a> .
Run Code Online (Sandbox Code Playgroud)
当我然后使用Knit HTML(在RStudio中)一切正常并且内部超链接工作正常但我也得到了一个不需要的
<p><a id="id1"></a>?</p>
Run Code Online (Sandbox Code Playgroud)
如何避免出现此错误?
我正在使用knitr来构建一个R包小插图.此过程在R 3.0之前有效,但我无法在R 3.1.1下重建该软件包.
当我尝试时R CMD build收到错误消息:
R CMD build Causata
* checking for file ‘Causata/DESCRIPTION’ ... OK
* preparing ‘Causata’:
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ...
ERROR Error in loadVignetteBuilder(vigns$pkgdir) :
vignette builder 'knitr' not found Calls: <Anonymous> -> loadVignetteBuilder
In addition:
Warning message: In tools::buildVignettes(dir = ".", tangle = TRUE) :
Files named as vignettes but with no recognized vignette engine:
‘vignettes/Causata-vignette.rnw’ (Is a VignetteBuilder field …Run Code Online (Sandbox Code Playgroud) 我正在使用RStudio和knitr将.Rmd编织为.docx
我想在图标题中包含内联代码,例如块选项中的以下内容:
fig.cap =" nrow(data)数据点图"
但是,knitr不会评估此代码,而只是打印未评估的命令.
有没有办法让knitr来评估图/表格标题中的r代码?
我已经在Linux mint和Windows 7上安装了Sweave和knitr软件包,它在Windows上运行良好,但在Linux中使用rstudio时却失败了.安装pkgs后,我写了一个简单的dw.Rnw如下:
\documentclass{article}
\begin{document}
The regression model is as follows
<<echo=TRUE>>=
pop=read.table("pop.txt",header=TRUE)
attach(pop)
lm.sol=lm(y~year)
summary(lm.sol)
@
\end{document}
Run Code Online (Sandbox Code Playgroud)
当我按下rstudio中的" 编译PDF " 按钮时,它会返回以下错误消息:
During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_COLLATE failed, using "C"
3: Setting LC_TIME failed, using "C"
4: Setting LC_MESSAGES failed, using "C"
5: Setting LC_PAPER failed, using "C"
6: Setting LC_PAPER failed, using "C"
7: Setting LC_MEASUREMENT failed, using "C"
> grDevices::pdf.options(useDingbats = …Run Code Online (Sandbox Code Playgroud) 在R中,capture.output()可以stdout将表达式中的输出捕获为字符向量,例如
> x = capture.output(print(1:10))
> x
[1] " [1] 1 2 3 4 5 6 7 8 9 10"
Run Code Online (Sandbox Code Playgroud)
朱莉娅有同等的功能吗?
所以我有一个小插曲,vignettes/test-vignette3.Rmd:
---
title: "Sample Document"
output:
html_document:
highlight: kate
theme: spacelab
toc: yes
pdf_document:
toc: yes
---
Header
=========
Run Code Online (Sandbox Code Playgroud)
当我按下knit HTML按钮时,我得到以下内容:
processing file: test-vignette3.Rmd
output file: test-vignette3.knit.md
Output created: /tmp/RtmpKVpegL/preview-5ef42271c0d5.dir/test-vignette3.html
Run Code Online (Sandbox Code Playgroud)
但是,如果我将此文件复制到inst/doc并按下knit HTML按钮,我会得到:
processing file: test-vignette3.Rmd
output file: test-vignette3.knit.md
Output created: test-vignette3.html
Run Code Online (Sandbox Code Playgroud)
我的问题是:
knit HTML上vignettes/test-vignette3.Rmw到小插图目录?test-vignette3.knit.md在knit HTML程序中如何让RStudio不被删除?(我想要.md所以人们可以在我的github回购中阅读.)我正在运行RStudio版本0.98.836,rmarkdown版本0.1.98和knitr版本1.5.
我不仅希望我的数字出现在我的knitr生成的报告中,而且我还希望将它们输出到单独的文件中.为此,我提供了如下代码:
```{r}
#Plot figure in report
plot(x,y)
#Plot figure in file
pdf(file="MyFig.pdf")
plot(x,y)
dev.off()
```
Run Code Online (Sandbox Code Playgroud)
这很好用,但我希望有一个更优雅的解决方案,已经内置到knitr.是否有一个块选项或类似的东西可以实现相同的结果?
我正在尝试使用此示例将3个文件编织在一起:http://rmarkdown.rstudio.com/rmarkdown_websites.html
我的文件都共享同一目录,该目录已在RStudio构建选项中设置.我用我自己的文件名从示例中复制了YML.即使我直接复制示例,我也会得到同样的错误.
我甚至从RMarkdown Github运行了site_generator函数:https://github.com/rstudio/rmarkdown/blob/master/R/render_site.R#L157
我注意到有自定义生成器的选项,我不想要.我想做的就是能够将几个降价文件编织到一个网页中,然后为每个页面/部分创建一个带有标签的导航栏.
我正在使用rmarkdown生成一个单词(.docx)报告.我想改变toc的标题.这似乎是可能的,pandoc_args因为在doc文件(1)的情况下可以作为yaml头中的选项传递.但我做得不对.有人能提供一个有效的例子吗?
(1)pandoc.args包含在rmarkdown可能的选项中,在pandoc手册中,有一个toc-title选项
---
title: "yaml header"
author: "cedric"
output:
word_document:
toc: true
pandoc_args: toc-title="Table des matières"
---
# One section
# Another
Run Code Online (Sandbox Code Playgroud)
这会产生:
我有一些 R markdown,其中包含以下代码:
```{r huff51, fig.show='hold', fig.cap='Design decisions connecting research purpose and outcomes [@huff_2009_designingresearchpublication p. 86].', echo=FALSE}
knitr::include_graphics('images/Huff-2009-fig5.1.svg')
```
Run Code Online (Sandbox Code Playgroud)
当使用 bookdown 生成 HTML 输出时,一切都按预期进行。
当使用 bookdown 生成 PDF 输出时,我收到一条错误消息! LaTeX Error: Unknown graphics extension: .svg.
这是可以理解的,因为 knitr 使用 Latex\includegraphics{images/Huff-2009-fig5.1.svg}来包含图像。所以,这本身并不是一个错误。
有没有更好的方法来包含 SVG 图像,这样我就不需要将其预处理为 PDF 或 PNG 等图像?