我正在尝试使用Shiny在flexdashboard中构建一个交互式表。以下reprex在Rstudio查看器中显示该表,但是CSV按钮不起作用。尝试在本地浏览器中打开时,该表未显示。
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(DT)
library(shiny)
df <- data_frame(
x = c("a", "b", "c", "c", "b", "c", "b", "a"),
y = c(1, 6, 7, 5, 9, 3, 8, 2),
z = c("one", "two", "three", "one", "two", "three", "one", "two")
)
```
Column {data-width=200 .sidebar}
-----------------------------------------------------------------------
```{r}
selectInput("x_input", label = "Select x Value",
choices = c("All", unique(as.character(df$x))), selected = "All")
roster_input <- reactive({
if (input$x_input=="All"){
df
}else{
df %>%
filter(x==input$x_input)}
})
```
Column {data-width=350}
-----------------------------------------------------------------------
### Chart B
```{r}
renderDataTable({
DT::datatable(
roster_input(),
rownames = FALSE,
filter = "top",
extensions = c('Buttons', 'Scroller'),
options = list(
dom = 'Blfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
deferRender = T,
scrollY = '400px',
scroller = TRUE))})
```
要在本地浏览器中运行该功能,我缺少什么?