How can I pass an argument to my shiny app?

久未见 提交于 2021-01-28 14:20:16

问题


I am trying to run a shiny application through a function called "OpenTree()", this function help me to start my application in the background but the issue that I have is that the argument of this function is fileName. I want that my shinyapp recognize the fileName that the function OpenTree returns and then deploy the app.

Example

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)

}

This is my server

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

Error in paste0("OpenTree will save your changes to the tree structure in real-time to output/",  : object 'fileName' not found

来源:https://stackoverflow.com/questions/65588060/how-can-i-pass-an-argument-to-my-shiny-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!