5

我正在使用 knitr 在 markdown (.Rmd) 文件中嵌入 R 代码。我正在使用 Pandoc 将文件转换为 PDF 文件。我的 .Rmd 文件的内容如下所示:

Report
========================================================

This is my report. Some analysis is included in LINK TO CHUNK NAMED MY.ANALYSIS HERE


```{r my.analysis, echo=FALSE}

summary(cars)

```

在此处显示 LINK TO CHUNK NAMED MY.ANALYSIS 的地方,我能否在输出的 PDF 中提供指向名为 my.analysis 的代码块的链接?

我相信 OP 在这里问了一个类似但略有不同的问题:figure captions, references using knitr and markdown to html

4

1 回答 1

2

做这个:

Report
========================================================

This is my report. Some analysis is included in \href{http://stackoverflow.com/q/16445247/1000343}{LINK TO CHUNK NAMED MY.ANALYSIS HERE}


```{r my.analysis, echo=FALSE}

summary(cars)

```

然后将markdown文件(不是Rmd)转换为PDF。

这也适用于报告的开发版本

```{r setup, include=FALSE}
# set global chunk options
opts_chunk$set(cache=TRUE)
library(reports); library(knitr); 
```
Report
========================================================

This is my report. Some analysis is included in `r HR("http://stackoverflow.com/q/16445247/1000343", "LINK TO CHUNK NAMED MY.ANALYSIS HERE")`


```{r my.analysis, echo=FALSE}

summary(cars)

```

然后将 html 文件转换为 pdf。

于 2013-05-08T17:26:01.770 回答