2017-04-12 94 views
1

我試圖用R生成一個flexdashboard並且想要在我的演示文稿中顯示代碼,但這似乎不起作用。 這裏一個小例子:在flexdashboard中顯示代碼

--- 
title: "Test" 
output: 
    flexdashboard::flex_dashboard 
--- 

```{r setup, include=FALSE} 
library(flexdashboard) 
``` 

### Code 

```{r, eval=FALSE, include=TRUE} 
plot(iris$Sepal.Length, iris$Sepal.Width) 
``` 

### Output 

```{r, fig.align='center', echo = FALSE} 
plot(iris$Sepal.Length, iris$Sepal.Width) 
``` 

enter image description here

fig.show = 'hide'即使其他盤選項將無法正常工作。 是否可以在flex-panel的R-chuck中顯示代碼?代碼突出顯示將是一種優點,而不是純文本。

回答

1

如果你想同時代碼和情節,以查看全套塊選項:echo = true

如果你只是想代碼將其設置爲:echo=TRUE, eval=FALSE

--- 
title: "Test" 
output: 
    flexdashboard::flex_dashboard 
--- 

```{r setup, include=FALSE} 
library(flexdashboard) 
``` 

### Code 

```{r, echo=TRUE, eval=FALSE} 
plot(iris$Sepal.Length, iris$Sepal.Width) 
``` 

### Code and Plot 

```{r, echo=TRUE} 
plot(iris$Sepal.Length, iris$Sepal.Width) 
``` 

### Plot 

```{r, fig.align='center', echo = FALSE} 
plot(iris$Sepal.Length, iris$Sepal.Width) 
``` 
0

它不會顯示爲面板在您的演示文稿中,但要將</> Source Code按鈕添加到您的儀表板,請在您的YAML中包含source_code: embed

--- title: "Example" output: flexdashboard::flex_dashboard: source_code: embed ---