コードの一部をシャイニーモジュールに変換しようとしていますが、lapply()
で生成されたrenderPlot()
関数が機能していないようです。私はこの問題を示すために以下の簡単な例を作成しました。シャイニーモジュールのrenderUI()で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)
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")
}
shinyApp(ui, server)
div
要素はすべて作成されていますが、プロット/テキストは含まれていません。 Shiny renderText()
またはrenderPlot()
の機能をモジュール内でrenderUI()
/lapply()
コール内で正しく使用するにはどうすればよいですか?
実際に私は 'renderText()'モジュールの例を取り出し、12(単に 'fluidRow(カラムを呼び出す場合、 paste( "Line"、val))) 'うまくいくようです。 – MrFlick
@MrFlick 'renderText()'を削除するとモジュールは 'lapply()'からテキストを出力することができますが、 'renderPlot()'関数を使っている私の実際のアプリケーションでは実装できません。 –
'renderUI()'が 'renderPlot()'を呼び出さずに 'plotOutput()'を出力しているはずです。 'renderPlot()'はそれらの出力の無効な値でなければなりません。 https://groups.google.com/forum/#!topic/shiny-discuss/HdCMHN8yjGM – MrFlick