俺最近想画一个可以调整宽度的直方图给用户看看,搜到 shiny 里面的selectInput()
刚好满足需求,可是含有 shiny 元素的 flexdashboard 的.Rmd保存以后就没有 knit 那个图标,而是变成一个绿色三角符号的 Run Document。我在 R Console 里面输入rmarkdown::render('test.Rmd')
后会报错,也无法生出来 html 文档。
File shared/selectize/css/selectize.bootstrap3.css not found in resource path
Error: pandoc document conversion failed with error 99
上网搜了搜,好像含有 shiny 元素的不管什么类型的文档都得部署到服务器上面去,就没别的路走了吗?
栗子代码
---
title: "举个栗子"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(echarts4r)
library(shiny)
```
```{r global, include=FALSE}
# 导入数据
data <-
data.frame(type = rep(c('A', 'B', 'C'), 100), value = sample(1:10000, 300))
```
## Inputs {.sidebar data-width=200}
```{r}
# shiny inputs defined here
selectInput(
"n_breaks",
label = "频数调整(等宽)",
choices = c(5, 10, 15, 20),
selected = 5)
```
## Row {data-height = 500}
### Chart A
```{r}
renderEcharts4r(
data |>
e_charts() |>
e_histogram(value, breaks = as.numeric(input$n_breaks)) |>
e_tooltip()|>
e_labels(show=TRUE,position = 'top')
)
```