GvisTables not showing up in Shiny apps

The actual problem I'm trying to solve is: I create a panel that will include data tables. I would like the numbers to be formatted with commas as thousands separators, but there is (apparently) a problem with the DT package when used with Shiny, since comma-separated formatting causes DT :: renderDataTable to read in numbers as a character, which affects sorting numbers. (The DT number formatting function does not work with Shiny, it appears.)

Where am I still: The only solution I could find is to use googleVis instead of DT to create tables. Now I am faced with another problem (described below), but I really need to have data tables with comma separated numbers that are sorted as numbers.

The problem with GoogleVis: . When I use gvisTable outside of Shiny apps, they look great, but they don’t appear at all when using renderGvis and htmlOutput in Shiny. As an example, I'll take Example 4 from here.

Without using Shiny, my code looks like this:

library(datasets)
library(googleVis)

myOptions <- list(page='enable', pageSize=10, width=550)

Table <- gvisTable(Population,options=myOptions)

plot(Table)

Using Shiny, it looks like this:

library(datasets)
library(googleVis)
library(shiny)

shinyApp(
  ui = pageWithSidebar(
    headerPanel("Example 4: pageable table"),
    sidebarPanel(
      checkboxInput(inputId = "pageable", label = "Pageable"),
      conditionalPanel("input.pageable==true",
                       numericInput(inputId = "pagesize",
                                    label = "Countries per page",10))
    ),
    mainPanel(
      htmlOutput("myTable")
    )
  ),
  server = function(input,output){
    myOptions <- reactive({
      list(
        page=ifelse(input$pageable==TRUE,'enable','disable'),
        pageSize=input$pagesize,
        width=550
      )
    })
    output$myTable <- renderGvis({
      gvisTable(Population,options=myOptions())
    }) 
  }
)

Any help is much appreciated!

+4
source share
1 answer

. , RStudio googleVis Shiny. , , Firefox... , - "woot" "ugh" .

+4

All Articles