使用具有光泽的flexdashboard在浏览器中渲染DT :: datatable

时间:2018-12-16 01:10:12

标签: r shiny flexdashboard

我正在尝试使用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))})
```

要在本地浏览器中运行该功能,我缺少什么?

0 个答案:

没有答案