Cross posted at Passing Shiny Object to R script - Stack Overflow
Is there a way that we can pass Shiny objects to embedded or outside R script? Like if I create a dateInput(let's say, ME_DATE) in ui and try to pass it in a sourced code later in server, how can it be done?...
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
dateInput("ME_DATE_output",label=h2("Execution Date"), value="2020-05-29")
)))
server = function(input, output) {
ME_DATE_GUI <- reactive({input$ME_DATE_output})
Code_loc <- "K:/Codes/"
ME_DATE <<- renderPrint({ ME_DATE_GUI() })
source(paste0(Code_loc,"Passed_R_code.r"))
}
And that Passed_R_code.R starts with -
ME_DATE <- as.Date(ME_DATE, format="%Y-%m-%d")
I also tried as.character
in it.
The error I get is -
Error in as.Date.default: do not know how to convert 'ME_DATE' to class “Date”
Clearly passed ME_DATE isn't taking a value in YYYY-MM-DD format but some function. I am hoping there might be a step/function to convert this. Any help is appreciated?
I tried this at Stackoverflow as well, but couldn't get any help so trying here -