2016-09-16 3 views
0

여러 개의 그림과 표가있는 보고서를 작성 중입니다. 나는 그들과 함께 텍스트를 참조하고 싶다.그림에 링크하는 R 마크 다운

--- 
title: "Test" 
output: 
    pdf_document 
--- 
Figure \ref{test} is a graph 

```{r test, fig.cap="This is a graph"} 

df <- data.frame(gp = factor(rep(letters[1:3], each = 10)), 
       y = rnorm(30)) 

ggplot(df, aes(x = gp, y = y)) + 
    geom_point() 
``` 

This is text to follow the diagram 

\pagebreak 

This is another page but can still link to Figure \ref{test} 

그러나 결과는 다음과 같습니다 : 나는 다음과 같은 노력했습니다

Figure ?? is a graph 
... 
This is another page but can still link to Figure ?? 

는 R 인하에서이 작업을 수행 할 수있는 기본 방법이 자신에게 write functions

답변

2

을하지 않고 내가 찾은 것 같아요 대답은 여기에 - https://github.com/yihui/knitr/issues/323

이 코드를 사용하면 제대로 이해한다면 당신이 찾고있는 행동을 제공하는 것 같았다.

--- 
title: "Test" 
output: 
    pdf_document 
--- 
Figure \ref{fig:plot} is a graph 

```{r plot-ref, fig.cap = "This is a graph\\label{fig:plot}"} 

library('ggplot2') 

df <- data.frame(gp = factor(rep(letters[1:3], each = 10)), 
       y = rnorm(30)) 

ggplot(df, aes(x = gp, y = y)) + 
    geom_point() 
``` 

This is text to follow the diagram 

\pagebreak 

This is another page but can still link to Figure \ref{fig:plot} 
+0

감사합니다. – pluke