Module 在模块中使用省略号
我想知道,是否可以使用省略号。。。在一个闪亮的服务器模块中。我认为问题在于我不能像通常使用括号那样调用被动值——服务器模块中的值 试图使省略号反应。。。也不管用。有人知道如何解决这个问题吗 提前谢谢Module 在模块中使用省略号,module,shiny,ellipsis,Module,Shiny,Ellipsis,我想知道,是否可以使用省略号。。。在一个闪亮的服务器模块中。我认为问题在于我不能像通常使用括号那样调用被动值——服务器模块中的值 试图使省略号反应。。。也不管用。有人知道如何解决这个问题吗 提前谢谢 renderPlotsUI = function(id) { ns = NS(id) tagList(plotOutput(ns("plot"))) } renderPlots = function(input, output, session, FUN, ...) { output$
renderPlotsUI = function(id) {
ns = NS(id)
tagList(plotOutput(ns("plot")))
}
renderPlots = function(input, output, session, FUN, ...) {
output$plot = renderPlot({FUN(...)})
}
# APP BEGINS
ui = fluidPage(
renderPlotsUI("plot1")
)
server = function(input, output, session) {
callModule(renderPlots, "plot1", FUN=plot, x = reactive(mtcars))
}
shinyApp(ui, server)
您可以将省略号转换为带有list的list,然后使用lappy和do.call调用函数。我稍微修改了您的示例,以展示如何将输入从ui传递到函数
library(shiny)
renderPlotsUI = function(id) {
ns = NS(id)
tagList(plotOutput(ns("plot")))
}
renderPlots = function(input, output, session, FUN, ...) {
output$plot = renderPlot({
args_evaluated <- lapply(list(...), function(x){x()})
do.call(FUN, args_evaluated)
})
}
shinyApp(
fluidPage(
sliderInput("n", "n", 1, 10, 5),
renderPlotsUI("plot1")
) ,
function(input, output, session) {
callModule(renderPlots, "plot1", FUN = plot, x = reactive({1:input$n}))
}
)