首页 > 解决方案 > R markdown flexdashboard - ramchart & highcharter - 显示问题

问题描述

我在 R Markdown (flexdashobard) 中显示图表时遇到问题。我有多个页面 (3)。在 R 设置中,我加载 RData。

什么时候:

而不是第一页和第二页中的图表,我看到了某种代码(它看起来像图表选项),在第三页中,所有内容都按原样显示。

在 R 设置中,我加载库 highcharter(它也在 .RData 中加载!),所有内容都显示在第一页和第二页中,但我在第三页(空白框)中看不到图表。

什么时候:

一切都按原样显示。

我到处使用选项:

{r,results='asis',echo=FALSE,fig.align='center',warning=FALSE, message=FALSE} 

您知道我应该使用哪些选项吗?

谢谢!

编辑 - 示例代码

示例 .R 代码:

library(rAmCharts)
library(highcharter)
library(rpivotTable)

#ramchart
chart_1 <- amPlot(x=iris$Sepal.Length, y=iris$Sepal.Width, col="orange")%>%
amLines(y=iris$Petal.Length, col="black")

chart_2 <- amPlot(x=iris$Sepal.Length, y=iris$Petal.Width, col="orange")%>%
amLines(y=iris$Petal.Length, col="black")

chart_3 <- amPlot(x=iris$Petal.Length, y=iris$Petal.Width, col="orange")%>%
amLines(y=iris$Petal.Length, col="black")


#pivot
pivot <- rpivotTable(iris, aggregatorName="Sum",  vals="Petal.Length", 
                             cols=c("Species"), rendererName="Line Chart" )

#highcharter
hchart_1 <-
highchart() %>% hc_chart(type = "column")%>%
  hc_xAxis(categories = iris$Species) %>%
  hc_add_series(data = iris$Sepal.Length, name = "Sepallength", color = "yellow", visible = TRUE)
    
    save.image("iristest.RData")

示例 R.Markdown 代码:

---
title: iris test
output: 
  flexdashboard::flex_dashboard:
    theme: yeti
    orientation: rows
    
---


```{r setup, include=FALSE}
load("iristest.RData")
```

highchart
=====================================  

Column {width=700px}
-----------------------------------------------------------------------
### Chart1

```{r,results='asis',echo=FALSE,fig.align='center',warning=FALSE, message=FALSE} 
### ch1
`hchart_1`
```

Column {width=700px}
-----------------------------------------------------------------------

### ch1
```{r,results='asis',echo=FALSE,fig.align='center',warning=FALSE,message=FALSE} 
### Chart1
`hchart_1`
```

pivot
=====================================   

Column {width=700px}
-----------------------------------------------------------------------
### pivot

```{r,results='asis',echo=FALSE,fig.align='center',warning=FALSE, message=FALSE} 
### 
pivot

```


ramchart {data-orientation=columns}
=====================================  
Column {width=700px}
-----------------------------------------------------------------------
### abc

```{r,results='asis',echo=FALSE,fig.align='center',warning=FALSE, message=FALSE} 
### abc
chart_1

```

### abc

```{r,results='asis',echo=FALSE,fig.align='center',warning=FALSE, message=FALSE} 
### abc
chart_3
```

标签: rr-markdownamchartsflexdashboardr-highcharter

解决方案


推荐阅读