2016-05-30 16 views
6

Tôi đã thêm nút tải xuống vào bảng flexdashboard trong bảng điều khiển bên cạnh, nhưng nó xuất hiện trong bảng chính khi tôi đan .RMD. Bạn có thể hướng dẫn tôi như thế nào để tôi có thể sửa chữa nó?Cách khắc phục sự cố thanh bên của nút tải xuống trong bảng mạch linh hoạt

Dưới đây là một ví dụ nhỏ về những gì tôi đang cố gắng để hoàn thành

--- 
title: "Download Button in Wrong Panel" 
output: 
    flexdashboard::flex_dashboard: 
    vertical_layout: scroll 
runtime: shiny 
--- 

```{r setup, include=FALSE} 

## Setting up required libraries 
library(flexdashboard) 
library(dplyr) 
library(shiny) 
library(knitr) 

dataset <- read.csv(somefile) 
``` 

Inputs {.sidebar} 
----------------------------------------------------------------------- 

### Input Filters 

```{r input} 

## Metric 1 
selectInput('metric', 
      'Choose Metric', 
      names(dataset %>% select(-default_column)), 
      selected = "default_metric") 

## Download Button 
downloadButton('downloadData','Download Result Set') 
``` 

Outputs 
----------------------------------------------------------------------- 

### List of Customers 

```{r output} 

subset_dataset <- reactive({ 
    dataset[,c("default_column",input$metric)] 
}) 

renderTable({ 
    subset_dataset() 
}, 
include.rownames = FALSE) 

downloadHandler(filename = function() { 
    paste('resultset-', Sys.Date(), '.csv', sep='') 
    }, 
    content = function(file) { 
    write.csv(subset_dataset(), file, row.names = FALSE) 
    } 
) 
``` 

Một ảnh chụp màn hình của bảng điều khiển như sau

enter image description here

Cảm ơn!

Trả lời

5

Đừng bận tâm, tôi đã sửa nó và thật là ngớ ngẩn khi tôi chưa thử trước khi đăng câu hỏi, nhưng nếu ai đó gặp phải vấn đề tương tự, giải pháp là ở đây.

Chức năng trình xử lý tải xuống cũng chỉ cần được đặt trong bảng điều khiển bên và điều đó cũng vậy.

Inputs {.sidebar} 
----------------------------------------------------------------------- 

### Input Filters 

```{r input} 

## Metric 1 
selectInput('metric', 
      'Choose Metric', 
      names(dataset %>% select(-default_column)), 
      selected = "default_metric") 

## Download Button 
downloadButton('downloadData','Download Result Set') 

downloadHandler(filename = function() { 
    paste('resultset-', Sys.Date(), '.csv', sep='') 
    }, 
    content = function(file) { 
    write.csv(subset_dataset(), file, row.names = FALSE) 
    } 
) 
Các vấn đề liên quan