我正在尝试在 Shiny.io 上上传一个 Shiny 的应用程序。应用程序被部署,当尝试链接时,应用程序因抛出错误而崩溃 与服务器断开连接 .当我检查仪表板的日志时,它显示 服务器错误:找不到函数“服务器” .
我无法找到解决方案。与此相关的文档和文章表明,所使用的包可能是导致错误的原因之一,但我无法找到兼容或不兼容的包列表。
这些是我的应用程序中使用的包/库列表,
提前致谢!!
更新
下面是可重现的 ui.R 和 server.R 脚本。
在调试时我发现这部分代码在部署时出错。
ui.R
library(shiny)
library(shinyBS)
library(shinycssloaders)
options(shiny.trace=TRUE)
shinyUI(pageWithSidebar(
fluidRow(
column(width = 4,height = 4,img(src='image.png', align = "left", height =
50, width = 200)),
column(8,titlePanel("Analysis"))
),
sidebarPanel(
br(),
fileInput("file1", label = (" Data "),multiple = F),
fluidRow(
column(12,align ="center", actionButton("button", "Analyze",style =
"background-color : skyblue", icon = icon("stats", lib =
"glyphicon"),width = 250 )))
),
mainPanel(
bsAlert("alert"),
br(),
fluidRow(
tabsetPanel(
tabPanel("Table",icon =
icon("table"),withSpinner(dataTableOutput('table'), type =
getOption("spinner.type", default = 8) ))
)
)
)
))
server.R
library(shiny)
library(shiny)
library(earth)
library(ggplot2)
library(plot3D)
library(visreg)
library(rgl)
library(zoo)
library(Hmisc)
library(dplyr)
library(gridExtra)
options(shiny.maxRequestSize=30*1024^2)
options(shiny.trace=TRUE)
if (interactive()){
shinyServer(function(input, output,session) {
dataframe <- reactive( {
### Create a data frame reading data file to be used by other
functions..
inFile <- input$file1
data1 <- read.csv(inFile$datapath, header = TRUE)
})
table1<- eventReactive(input$button, dataframe())
output$table <- renderDataTable({table1()})
})
}
谢谢!
最佳答案
最后我能够调试代码并找到错误的解决方案。
来自 Server.R
删除声明if (interactive())
并删除 session
来自 shinyServer(function(input,output,session))
的参数.
因此部署没有任何错误。
替换以下 server.R 脚本,它应该可以正常工作。
library(shiny)
library(shiny)
library(earth)
library(ggplot2)
library(plot3D)
library(visreg)
library(rgl)
library(zoo)
library(Hmisc)
library(dplyr)
library(gridExtra)
options(shiny.maxRequestSize=30*1024^2)
options(shiny.trace=TRUE)
shinyServer(function(input, output) {
dataframe <- reactive( {
### Create a data frame reading data file to be used by other functions..
inFile <- input$file1
data1 <- read.csv(inFile$datapath, header = TRUE)
})
table1<- eventReactive(input$button, dataframe())
output$table <- renderDataTable({table1()})
})
关于r - 在 Shiny.io 中上传应用程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47029141/