我正在尝试将一段代码转换为Shiny Module,但是renderPlot()在内部生成的函数lapply()似乎无法正常工作。我在下面创建了一个简单的示例来演示该问题。
(注意:这里我使用的是renderText()电话,但适用相同的行为。)
app_normal.R:
library(shiny)
ui <- fixedPage(
h2("Normal example"),
uiOutput("test")
)
server <- function(input, output, session) {
output$test <- renderUI({
lapply(1:3, function(val) {
fluidRow(column(12,renderText(paste("Line", val))))
})
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)
app_module.R:
library(shiny)
myModuleUI <- function(id) {
ns <- NS(id)
uiOutput(ns("test"))
}
myModule <- function(input, output, session) {
output$test <- renderUI({
lapply(1:3, function(val) {
fluidRow(column(12,renderText(paste("Line", val))))
})
})
}
ui <- fixedPage(
h2("Module example"),
myModuleUI("test_module")
)
server <- function(input, output, session) {
callModule(myModule, "test_module") …Run Code Online (Sandbox Code Playgroud)