[英]R Shiny, shinyapps.io printing error messages for R codes
我试图创建一个 Shiny 应用程序,它获取代码块并运行代码,然后为该代码块提供 output。
为此,我使用 textInput,然后使用以下内容尝试为用户提供输出。
Question1 <- reactive({
eval(parse(text=input$Question1_code))
})
output$Question1_output <- renderText({
input$Run_Code
isolate(paste(Question1()))
})
现在,我的问题是当我在本地运行它时,我得到的 output 是因为错误的语句/代码,例如
seq(1,10,-2)
'by' 参数中的符号错误。 (这是我希望看到的错误陈述)
但是,当我在 shinyapps.io 上运行它时,我收到以下错误消息,
发生了错误。 检查您的日志或联系应用作者进行澄清。
如何在 shinyapps.io 上打印我在本地收到的相同错误消息(错误的“by”参数登录)?
使用来自shinyCatch
的shinyCatch
您的案例示例:
library(shiny)
library(spsComps)
ui <- fluidPage(
actionButton("a", "blocking"),
actionButton("b", "no blocking"),
)
server <- function(input, output, session) {
observeEvent(input$a, {
spsComps::shinyCatch({
seq(1,10,-2)
},
# blocking recommended
blocking_level = "error",
prefix = "My-project" #change console prefix if you don't want "SPS"
)
# some other following actions will NOT be run
print("other actions")
})
# if you dont want to block
observeEvent(input$b, {
spsComps::shinyCatch({
seq(1,10,-2)
}, prefix = "My-project")
# some other following actions will run
print("other actions")
})
}
shinyApp(ui, server)
或在此处尝试更多演示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.