I pass some parameters to this function (I make a reprex below) and works.
myReporter <- function(
reports,
data,
...
){
blah
blah
}
par <- list(
Min = 202201,
Max = 202204,
closingmonth = 12
)
rpt <- do.call(
myReporter,
c(
list(
reports = reports,
data = data
),
par
)
)
and works
But when I try to use reactive expressions, the dot-dot-dot does not work anymore. Inside myReporter
function, the reactives' elements are still unevaluated, tought I put in their invocation parenthesis par() to force their evaluation before go inside.
par <- reactive({list(
Min = input$min,
Max = input$max,
closingmonth = input$closingmonth
)})
rpt <- do.call(
myReporter,
c(
list(
reports = reports,
data = data
),
par() #force evaluation
)
)
MyReporter is not prepared to accept reactive expression, so I need to force their parameters to be evaluated before.
I left similar problem I guess in this Reprex
REPREX:
library(shiny)
ui <- fluidPage(
numericInput("x1", "x1", value = 2),
numericInput("x2", "x2", value = 2),
numericInput("power_dotodotdot_1", "power_x1", value = 2),
numericInput("power_dotodotdot_2", "power_x2", value = 2),
verbatimTextOutput("res")
)
server <- function(input, output) {
makeaverage <- function(x1, x2, ...){
if(exists("power_x1")){x1 <- x1^power_x1}
if(exists("power_x2")){x2 <- x2^power_x2}
res <- (x1 + x2)/2
return(res)
}
dots <- reactive(
list(
power_x1 = input$power_dotodotdot_1,
power_x2 = input$power_dotodotdot_2
)
)
output$res <- renderText({
do.call(
makeaverage,
c(
x1 = input$x1,
x2 = input$x2,
),
dots()
)
})
}
shinyApp(ui, server)
any ideas?