2017-04-12 90 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 ---