我试图通过一个名为“OpenTree()”的函数运行一个闪亮的应用程序,这个函数帮助我在后台启动我的应用程序,但我遇到的问题是这个函数的参数是文件名。我希望我的 Shinyapp 识别函数 OpenTree 返回的文件名,然后部署应用程序。
示例
createTree <- function(fileName) {
path_aux <- paste0("output/OpenTree_",fileName, ".json")
path_aux <- paste0(path_aux)
assign("path", path_aux, envir = .GlobalEnv)
assign("fileName", path_aux, envir = .GlobalEnv)
rstudioapi::jobRunScript(path = "shiny-run.R")
return(fileName)
}
这是我的服务器
server <- function(input, output, session){
# First Message
message <- paste0("OpenTree will save your changes to the tree structure in real-time to output/", fileName, ".json")
# send the message to the event handler with name handler1 if we press the action button
session$sendCustomMessage("handler1", message)
# This block fires each time we receive a message from JavaScript
output$table2 <- renderTable({
#Write json file
json_value = input$jsonData
write(json_value, paste0("output/",fileName, ".json"))
})
}
错误
Error in paste0("OpenTree will save your changes to the tree structure in real-time to output/", : object 'fileName' not found