DT :: dataTableOutput()不能在Shiny Server上运行,但在从R Studio运行时可以正常工作

时间:2017-12-03 09:34:02

标签: r shiny shiny-server rstudio-server

您好我遇到的问题是DT::dataTableOutput("table")命令导致r闪亮服务器崩溃并报告"错误:发生了错误。检查您的日志或联系应用程序作者以获得澄清。"有趣的是,闪亮的应用程序从我的本地计算机上运行得很好,甚至在从R studio服务器实例运行它时也没有问题,即你的服务器:8787。我在由Linode托管的Ubuntu 16.04 VM上运行服务器。完全披露这是我第一次在Ubuntu工作,更不用说完全从终端导航了。我的观点是我无法从Ubuntu终端提取错误日志,因为虽然我知道它们在哪里但我不知道用什么命令来打开它们。我的问题是当应用程序从RStudio运行时,为什么服务器崩溃?

library(shiny)
library(ggplot2)  
library(readr)
library(shinyjs)
library(DT)

GData <- structure(list(Model = structure(1:2, .Label = c("G17", "G19"), class = "factor"), 
                          Maker = c("G_Inc", "G_Inc"), Type = c("P","P"), 
                          OLength = c(8.03, 8.03), 
                          Length = c(4.48, 4.48), 
                          Site = c(6.49,6.49), 
                          rad = c(1.26, 1.26), 
                          HOB = c(1.18, 1.18), 
                          Width = c(1.18,1.18),
                          BWidth = c(25.06, 25.06), 
                          Weight = c(32.12, 32.12), 
                          WieghtL = c(5.5,5.5), 
                          TPull_lb = structure(c(1L, 1L), .Label = "Striker", class = "factor"),
                          Te = c(17L, 15L), 
                          C_Standard = c(9, 9), 
                          Cer = structure(c(1L,1L), 
                                          .Label = "Para", class = "factor")), 
                     .Names = c("Model","Maker", "Type", "OLength", "Length", "Site", "rad", "HOB", "Width", 
                                                                                                               "BWidth", "Weight", "WieghtL", "TPull_lb", "Te", "C_Standard", 
                                                                                                               "Cer"), row.names = c("1", "2"), class = "data.frame")

ui <- navbarPage(
  title = "Resorces",
  tabPanel("Search Tool",
           sidebarPanel(
             sliderInput("OveralLength", "Overal Length",
                         min = 2, max = 16,
                         value = c(5,10),step=0.1,post=" in"),
             sliderInput("integer1", "BLength",
                         min = 1, max = 10,
                         value = c(3,6),step=0.1,post=" in"),
             sliderInput("integer2", "TPull",
                         min = 0, max = 15,value = c(3,8),step=0.1,post=" lbs"),
             sliderInput("C_Standard", "Cap",
                         min = 0, max = 33,
                         value = 10),
             selectInput("man",
                         "Manufacturer:",
                         c("All",
                           unique(as.character(GData$Maker)))),
             useShinyjs(),
             actionButton("SelectCol", "Show Columns"),
             actionButton("SelectColOFF", "Hide Columns"),
             hidden(
               checkboxGroupInput("show_vars", "Select Columns to Show",
                                  names(GData), selected = names(GData))) 

             ,width=3),
           mainPanel(
             tabsetPanel(id="tabs",
                         tabPanel("Hg", 
                                  # Output: Table summarizing the values entered ----
                                  DT::dataTableOutput("table")),
                         tabPanel("Rif"),
                         tabPanel("Sho"),
                         tabPanel("BP"),
                         tabPanel("Misc")
             )
           )
  ),
  tabPanel("C_Database"),
  tabPanel("W_Center")
)
server <- function(input, output) {

  observeEvent(input$SelectCol, {
    show("show_vars")
  })
  observeEvent(input$SelectColOFF, {
    hide("show_vars")
  })


  # Create gun table
  output$table <- DT::renderDataTable({
    DT::datatable(subset(GData[, input$show_vars, drop = FALSE]))
  })
}


shinyApp(ui, server)

0 个答案:

没有答案