Passing Shiny Object to R script

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 -

Just an admin note on our cross-posting policy: FAQ: Is it OK if I cross-post?

Sorry, I couldn't get any response on Stackoverflow, so thought of checking here!

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.