2017-08-05 3 views
0

私のシャイニーアプリケーションに関連するコードは次のとおりです。追加のコードが必要な場合はお知らせください。私はプロットをレンダリングするために同じメソッドを使用することができますが、テーブルをレンダリングしようとするとエラーが発生しています。シャイニーはアクションボタン付きのテーブルを更新します

UI:数のエラー:未使用の引数(

actionButton("do", "Test!"), 

fluidPage(
     tableOutput('table1') 
), 

Serverの私は、 "テスト" ボタンを押すと

しかし
globals <- reactiveValues(
    mydf = dat 
    ) 

    count <- eventReactive(input$do, { 
    filter_mk <- input$mk 
    filter_date <- input$date 
    filter_universe <- input$universe 

    dat_f <- globals$mydf %>% filter(date >= filter_date & universe %in% filter_universe & mrkcp_buckets %in% filter_mk) 

    count <- dat_f %>% 
     group_by(date) %>% 
     count() %>% 
     rename(st = n) %>% 
     group_by(strftime(date, "%Y-%m")) %>% 
     filter(date == max(date)) %>% 
     ungroup() %>% 
     select(`strftime(date, \"%Y-%m\")`, st) %>% 
     spread(`strftime(date, \"%Y-%m\")`, st) %>% 
     .[seq(1, length(.), 3)] 

}) 

output$table1 <- renderTable({ 
    count() 
}, caption= "Test", 
caption.placement = getOption("xtable.caption.placement", "top") 
) 

、私は次のエラーを取得しています)。私が何か簡単なものを見逃しているのだろうかと思います。

私もできませんobserveEvent(input$do, {output$table2 <- renderTable({.})私は簡潔にしようとしなかったいくつかの他の制約をします。

答えて

0

count関数を呼び出すときにパッケージを指定する必要があると仮定します.Rは反応カウントオブジェクトと混同する可能性があるからです。

完全な実施例は、この(私はその近くに、十分なあなたに願っていますが、完全な最小作業例を提供didntのように、私はいくつかの推測をしなければならなかった)次のようになります。

ui <- fluidPage(
sidebarLayout(
    sidebarPanel(
    actionButton("do", "Test!"), 
    # as a substitute for mk etc 
    numericInput("numbers", "Max Group_n", min = 1, max = 1000, value = 100) 
), 
    tableOutput('table1') 
) 
) 


server <- function(input, output) { 
library(dplyr) 

globals <- reactiveValues(
    mydf = data.frame(x = 1:1000, 
        y = rnorm(1000), 
        group = sample(LETTERS[1:10], 1000, T)) 
) 

count <- eventReactive(input$do, { 
    filter_n <- input$numbers 

    dat_f <- globals$mydf 

    count <- dat_f %>% 
    group_by(group) %>% 
    # make sure that we use dplyr's count and not the reactive count... 
    dplyr::count() %>% 
    filter(n >= filter_n) 

}) 


output$table1 <- renderTable({ 
    count() 
}, caption = "Test", caption.placement = getOption("xtable.caption.placement", "top")) 
} 

shinyApp(ui = ui, server = server) 

がいることをいあなたのために働く?

関連する問題