在 flexdashboard 上显示 nvd3 rChart
Display nvd3 rChart on flexdashboard
我正在尝试使用 flexdashboard
获取要呈现的 nvd3
图表。谁能指出我做错了什么?我已经尝试了一些东西,下面是我尝试过的两个例子。
感谢您的帮助。
flex.Rmd
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(rCharts)
library(knitr)
library(shiny)
dat <- data.frame(
t = rep(0:23, each = 4),
var = rep(LETTERS[1:4], 4),
val = round(runif(4*24,0,50))
)
output$chart1 <- renderChart({
chrt1 <- nPlot(val ~ t, group = 'var', data = dat,
type = 'stackedAreaChart', id = 'chart')
return(chrt1)
})
chrt1 <- nPlot(val ~ t, group = 'var', data = dat,
type = 'stackedAreaChart', id = 'chart')
```
Column {data-width=650}
-----------------------------------------------------------------------
### Chart A
```{r}
# showOutput("chart1", "nvd3")
renderChart({ chrt1$print("hi") })
```
通过集成闪亮的应用程序实现了它。如果有更清洁的解决方案,我仍然会感兴趣。谢谢
### Chart A
```{r}
shinyApp(
ui =
mainPanel(
showOutput("nplot01", "nvd3")
),
server = function(input, output){
output$nplot01 <- renderChart({
n1 <- nPlot(val ~ t, group = 'var', data = dat,
type = 'stackedAreaChart', id = 'chart')
n1$addParams(dom="nplot01", "nvd3")
n1
})
}
)
```
我正在尝试使用 flexdashboard
获取要呈现的 nvd3
图表。谁能指出我做错了什么?我已经尝试了一些东西,下面是我尝试过的两个例子。
感谢您的帮助。
flex.Rmd
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(rCharts)
library(knitr)
library(shiny)
dat <- data.frame(
t = rep(0:23, each = 4),
var = rep(LETTERS[1:4], 4),
val = round(runif(4*24,0,50))
)
output$chart1 <- renderChart({
chrt1 <- nPlot(val ~ t, group = 'var', data = dat,
type = 'stackedAreaChart', id = 'chart')
return(chrt1)
})
chrt1 <- nPlot(val ~ t, group = 'var', data = dat,
type = 'stackedAreaChart', id = 'chart')
```
Column {data-width=650}
-----------------------------------------------------------------------
### Chart A
```{r}
# showOutput("chart1", "nvd3")
renderChart({ chrt1$print("hi") })
```
通过集成闪亮的应用程序实现了它。如果有更清洁的解决方案,我仍然会感兴趣。谢谢
### Chart A
```{r}
shinyApp(
ui =
mainPanel(
showOutput("nplot01", "nvd3")
),
server = function(input, output){
output$nplot01 <- renderChart({
n1 <- nPlot(val ~ t, group = 'var', data = dat,
type = 'stackedAreaChart', id = 'chart')
n1$addParams(dom="nplot01", "nvd3")
n1
})
}
)
```