我想发布一个 Rshiny 应用程序。当我在笔记本电脑上运行代码时没有错误,但是当我想发布应用程序时会弹出此错误:
发生了错误。检查您的日志或联系应用作者进行澄清。
我认为错误来自我的 Excel 加载代码“目录名”,但我不知道如何修复它。有人可以帮助我吗?
这是我的代码:
test <- function (x){
#load Excel file
dirname <- '~/Testlocation'
if (!dir.exists(dirname))dir.create(dirname,recursive=TRUE)
testfile <- read.xlsx("testfile.xlsx", sheet = 1)
return(testfile[x,1])
}
ui <- fluidPage(
numericInput("x",
label = "what is x?",
value = "5"),
textOutput("output1"))
server <- function(input, output) {
output$output1 <- renderText({test(input$x)})}
shinyApp(ui, server)
这就是代码的意思:如果你用 x 输入一个数字,例如 15,那么它将在数据框“testfile”中搜索第 15 行和第一列。这是应用程序:
有人可以帮助我吗?