2016-07-13 4 views
1

私はformatPercentage,rowname=FALSEをrenderDataTableに使用したいと思います。方法1にはformatPercentageが含まれ、方法2にはrowname=FALSEが含まれています。私はそれらを一緒にマージしたいが、エラーを取得し続ける(renderDataTable ignores ... arguments when expr yields a datatable object; see ?renderDataTable)。これはどうすればいいですか?formatPercentageとrenderDataTableを一緒に使用する方法

方法1 formatPercentageが含まれていますが、renderDataTableオプションを渡すことはできません。

# Method 1 format Percentage 
output$funddetails <- DT::renderDataTable(
     DT::datatable({ 
     heatmap_raw[heatmap_raw$Keeper%in% 
        input$selectkeeper&month(heatmap_raw$period)%in% 
        input$selectmonth,c("apid","Fund Name","Status","Comments","Last Update by Keeper","Most Recent Portfolio")] 
     })%>%formatPercentage(1, 2) 
) 

方法2のみrenderDataTableするためのオプションが含まれていますが、私はformatPercentageを使用することはできません。

#Method 2 
data_fund <- reactive({ 
    heatmap_raw[heatmap_raw$Keeper%in% 
     input$selectkeeper&month(heatmap_raw$period)%in% 
     input$selectmonth,c("apid","Fund Name","Status","Comments","Last Update by Keeper","Most Recent Portfolio")] 
}) 

output$funddetails <- DT::renderDataTable(
    data_fund(), 
    rowname=FALSE, 
    options = list(
    pageLength=10, 
    #autoWidth = TRUE, 
    lengthMenu = list(c(25, 50, -1), c('25', '50', 'All')), 
    searchHighlight = TRUE, 
    scrollX=TRUE 
) 
) 

答えて

0

私はとあなたの問題を考えます方法1は、datatableコマンドの中括弧の位置によるものです。あなたは実際にそれらを必要としません。あなたに適した例を次に示します。

library(shiny) 

shinyApp(

    ui = fluidPage(
    DT::dataTableOutput('tbl') 
), 

    server = function(input, output) { 
    output$tbl = DT::renderDataTable(
     datatable(iris, 
       rowname=FALSE, 
       options = list(
        pageLength=10, 
        #autoWidth = TRUE, 
        lengthMenu = list(c(25, 50, -1), c('25', '50', 'All')), 
        searchHighlight = TRUE, 
        scrollX=TRUE) 
    ) %>% formatPercentage(1, 2) 
    ) 
    } 
) 
関連する問題